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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…