You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/pages/ble_screen.dart

58 lines
1.5 KiB
Dart

2 years ago
import 'package:diplomaticquarterapp/viatom_ble/ble_connect.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:photo_view/photo_view.dart';
class BLEScreen extends StatefulWidget {
@override
State<BLEScreen> createState() => _BLEScreenState();
}
class _BLEScreenState extends State<BLEScreen> {
EventChannel eventChannel = EventChannel('BLE-Platform-Bridge-Event');
2 years ago
String receivedData = '';
2 years ago
@override
void initState() {
// TODO: implement initState
super.initState();
eventChannel.receiveBroadcastStream().listen((event) {
// Handle the received event here.
print('Received event---: $event');
setState(() {
2 years ago
receivedData = event;
2 years ago
});
// You can update your UI or perform any other actions based on the event.
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: GestureDetector(
onTap: () async {
2 years ago
await BleChannel.getScanningResult();
2 years ago
},
child: Container(
width: 50,
height: 50,
color: Colors.blueAccent,
),
),
),
2 years ago
Center(child: Text(receivedData))
2 years ago
],
),
),
);
}
}