Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr<int>'
See original GitHub issueI cant read the state of bluetooth if there is any connected device? I want to kniow if there is a connected device and return that device. But on state am getting this error; BluetoothPrint.state.<anonymous closure> (package:bluetooth_print/bluetooth_print.dart:64:60)
/// Gets the current state of the Bluetooth module
Stream<int> get state async* {
yield await _channel.invokeMethod('state').then((s) => s); //-----------line no 64
yield* _stateChannel.receiveBroadcastStream().map((s) => s);
}
` // Platform messages are asynchronous, so we initialize in an async method. Future<void> initBluetooth() async { bluetoothPrint.startScan(timeout: Duration(seconds: 4));
bool? isConnected = await bluetoothPrint.isConnected;
bluetoothPrint.state.listen((state) {
print('cur device status: $state');
switch (state) {
case BluetoothPrint.CONNECTED:
setState(() {
_connected = true;
tips = 'connect success';
});
break;
case BluetoothPrint.DISCONNECTED:
setState(() {
_connected = false;
tips = 'disconnect success';
});
break;
default:
break;
}
});
if (!mounted) return;
if(isConnected!) {
setState(() {
_connected=true;
});
}
}`
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5
Top Results From Across the Web
flutter - Unhandled Exception: type 'Null' is not a subtype of ...
i have tried to turn Future to nullable and also the string but something goes wrong any help please? floatingActionButton: FloatingActionButton ...
Read more >Unhandled Exception: type 'Null' is not a subtype of ... - GitHub
Unhandled Exception : type 'Null' is not a subtype of type ... I got this exception when I'm trying to purchase consumable items....
Read more >type 'Null' is not a subtype of type 'String' : r/flutterhelp - Reddit
Hey everyone, I'm a flutter newbie and I came across this error when running my app despite the fact that my ide didn't...
Read more >the argument type 'future<dynamic>' can't be assigned to the ...
Type dynamic can be null , but Object can't be null . ... Unhandled Exception: type 'Future<dynamic>' is not a subtype of type...
Read more >type 'Null' is not a subtype of type 'String' in type cast flutter
This will fix the error type 'int' is not a subtype of type 'double' To fix type 'double' is not a subtype of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this problem still exist on version 4.1.0, anyone solved this problem ? can’t run example project it keeping this error 😞
latest version , no problem.