How can I look for an interrupt sent over from Bluetooth on my Flutter app? StreamBuilder/FutureBuilder

Viewed 36

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