bluetooth_print
bluetooth_print copied to clipboard
Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr<int>'
I 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.
/// 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
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;
});
}
}`
i'm getting this error only on iOS. Were you able to solve it?
i'm getting this error only on iOS. Were you able to solve it?
No... Still straggling
I used on
i'm getting this error only on iOS. Were you able to solve it?
No... Still straggling
I used this fork https://github.com/foresightmobile/bluetooth_print/tree/dev. Dev branch. Works fine
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.