Getting errors with using a flutter blue code

Viewed 31

I am trying to run a flutter blue code that is from the examples of the library(https://github.com/pauldemarco/flutter_blue/blob/master/example/lib/widgets.dart). I'm getting few errors. The part of the code that is doing the problems is shown in the image the error message that I'm getting is that: "The argument type 'List<dynamic>' can't be assigned to the parameter type 'List<Widget>'". The code is as

      StreamBuilder<List<ScanResult>>(
        stream: FlutterBlue.instance.scanResults,
        initialData: [],
        builder: (c, snapshot) => Column(
          children: snapshot.data!
              .map(
                (r) => ScanResultTile(
                  result: r,
                  onTap: () => Navigator.of(context)
                      .push(MaterialPageRoute(builder: (context) {
                    r.device.connect();
                    return DeviceScreen(device: r.device);
                  })),
                ),
              )
              .toList(),
        ),
      )

The second part of the code is:

 List<Widget> _buildServiceTiles(List<BluetoothService> services) {
    return services
        .map(
          (s) => ServiceTile(
            service: s,
            characteristicTiles: s.characteristics
                .map(
                  (c) => CharacteristicTile(
                    characteristic: c,
                    onReadPressed: () => c.read(),
                    onWritePressed: () async {
                      await c.write(_getRandomBytes(), withoutResponse: true);
                      await c.read();
                    },
                    onNotificationPressed: () async {
                      await c.setNotifyValue(!c.isNotifying);
                      await c.read();
                    },
                    descriptorTiles: c.descriptors
                        .map(
                          (d) => DescriptorTile(
                            descriptor: d,
                            onReadPressed: () => d.read(),
                            onWritePressed: () => d.write(_getRandomBytes()),
                          ),
                        )
                        .toList(),
                  ),
                )
                .toList(),
          ),
        )
        .toList();
  }

You can also find the code in the https://github.com/pauldemarco/flutter_blue/blob/master/example/lib/widgets.dart enter image description here

enter image description here

0 Answers
Related