我该如何查找从flutter应用程序上从蓝牙发送的中断? StreamBuilder/FutureBuilder

发布于 2025-02-08 04:39:30 字数 1381 浏览 2 评论 0原文

我该如何查找从flutter应用程序上从蓝牙发送的中断?目前,我正在使用StreamBuilder尝试使用它,但这仅在应用程序的另一个状态更改时获取数据。

我的应用程序通过蓝牙连接到加速度计,我想在应用程序上流式传输和显示警报。

                new Container(
                  padding: new EdgeInsets.only(left: 15),
                  child: new Column(children: <Widget>[
                    StreamBuilder<List<int>>(
                        stream: button_1?.value,
                        initialData: button_1?.lastValue,
                        builder: (c, snapshot)  {
                          final value = snapshot.data;

                          final msg = new StringBuffer();
                          print("MSG IS HERE");
                          print(msg);
                          value?.forEach((v) {
                            msg.write(String.fromCharCode(v));
                          });
                          String at = '1';


                          return Text(

                            msg.toString() == ''
                              ? alertMessage
                               : msg.toString(),
                            style: new TextStyle(
                              color: Colors.black,
                              fontWeight: FontWeight.w600,
                              fontSize: 16.0,
                            ),
                          );
                        }),

How can I look for an interrupt sent over from Bluetooth on my Flutter app? Currently I am trying it with StreamBuilder but this is only getting the data when another state of the APP changes.

My App is connected to an accelerometer via bluetooth and I want to stream and display alerts on my app.

                new Container(
                  padding: new EdgeInsets.only(left: 15),
                  child: new Column(children: <Widget>[
                    StreamBuilder<List<int>>(
                        stream: button_1?.value,
                        initialData: button_1?.lastValue,
                        builder: (c, snapshot)  {
                          final value = snapshot.data;

                          final msg = new StringBuffer();
                          print("MSG IS HERE");
                          print(msg);
                          value?.forEach((v) {
                            msg.write(String.fromCharCode(v));
                          });
                          String at = '1';


                          return Text(

                            msg.toString() == ''
                              ? alertMessage
                               : msg.toString(),
                            style: new TextStyle(
                              color: Colors.black,
                              fontWeight: FontWeight.w600,
                              fontSize: 16.0,
                            ),
                          );
                        }),

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文