简体   繁体   中英

How to use flutter_blue in background isolate to scan & connect with BLE device

I would like to find and connect bluetooth devie on background isolate without any diplay. I develop app using flutter dart. I found a good example using flutter_blue 0.7.3 that starts with the following widget. How can I do this part in background, especially

StreamBuilder<BluetoothState> ? 

Thanks

--link to example https://pub.dev/packages/flutter_blue/example

---widget

class FlutterBlueApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      color: Colors.lightBlue,
      home: StreamBuilder<BluetoothState>(
          stream: FlutterBlue.instance.state,
          initialData: BluetoothState.unknown,
          builder: (c, snapshot) {
            final state = snapshot.data;
            if (state == BluetoothState.on) {
              return FindDevicesScreen();
            }
            return BluetoothOffScreen(state: state);
          }),
    );
  }
}

i decided to connect to using displayed widgets and check the messages ia timer and display status using providerq in the main page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM