Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

flutter - MissingPluginException(No implementation found for method isAvailable on channel plugins.pauldemarco.com/flutter_blue/methods)

My flutter app. Im trying to get all BLE devices in the backgroung, activated form printHello() function.

I have the following error: The error at the following line - FlutterBlue _flutterBlue = FlutterBlue.instance;

Does someone have new information about? I saw similar questions and try to implement them, but I could not solve the issue.

Here is the logcat:

I/flutter (20509): [2021-02-04 18:39:34.118258] Start Scanning
I/flutter (20509): [2021-02-04 18:39:34.118258] end of scanning
E/flutter (20509): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method isAvailable on channel plugins.pauldemarco.com/flutter_blue/methods)
    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      final int helloAlarmID = 0;
      await AndroidAlarmManager.initialize();
      runApp(MyApp());
      await AndroidAlarmManager.periodic(const Duration(seconds: 30), helloAlarmID, printHello);
    }

    void printHello() {
      final DateTime now = DateTime.now();
      final int isolateId = Isolate.current.hashCode;
      print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
      _getDevices();
    
    }

    void _getDevices() {
      final DateTime now = DateTime.now();
      print("[$now] Start Scanning");
       bool _found = false;
       FlutterBlue _flutterBlue = FlutterBlue.instance;
      _flutterBlue.startScan(timeout: Duration(seconds: 4));
      var subscription = _flutterBlue.scanResults.listen((results) {
        for (ScanResult r in results) {
    //      print('111 ${r.device.name} 2 ${r.device.id } 3 found! rssi: ${r.rssi}');
          if (('${r.device.id }'=="XXX" )& (_found==false)) { print ("[$now] ----------");_found = true;     
     }
        }
        });
      _flutterBlue.stopScan();
      print("[$now] end of scanning");
    
    }

question from:https://stackoverflow.com/questions/66050296/missingpluginexceptionno-implementation-found-for-method-isavailable-on-channel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...