【问题标题】:How to use flutter_blue in background isolate to scan & connect with BLE device如何在后台隔离中使用flutter_blue扫描并连接BLE设备
【发布时间】:2021-05-21 09:30:39
【问题描述】:

我想在没有任何显示的情况下在后台隔离上查找并连接蓝牙设备。 我使用颤振飞镖开发应用程序。 我找到了一个使用 flutter_blue 0.7.3 的好例子,它以以下小部件开头。 我怎样才能在后台做这部分,尤其是

StreamBuilder<BluetoothState> ? 

谢谢

--链接到示例 https://pub.dev/packages/flutter_blue/example

---小部件

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);
          }),
    );
  }
}

【问题讨论】:

    标签: flutter dart bluetooth stream-builder dart-isolates


    【解决方案1】:

    我决定使用显示的小部件连接并检查消息 i 一个计时器并在主页中使用 providerq 显示状态

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多