question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr<int>'

See original GitHub issue

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.<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:open
  • Created a year ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
YouSourcommented, Oct 28, 2022

this problem still exist on version 4.1.0, anyone solved this problem ? can’t run example project it keeping this error 😞

0reactions
YouSourcommented, Nov 2, 2022

latest version , no problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found