Closed Wang-code-say closed 11 months ago
@pragma('vm:entry-point')
static void startWifiScan(StreamController<List
static void wifiScanIsolate(SendPort wifiSendPort) async { const Duration interval = Duration(seconds: 5); const String prefix = "admin"; await for (var wifiList in scanWifiNetworks(interval, prefix)) { final serializedList = wifiList.map((wifi) => wifi.toJson()).toList(); if (serializedList.isNotEmpty) { wifiSendPort.send(serializedList); } else { FlutterIsolate.current.kill(); } } }
static Stream<List
yield ssidSet.toList();
await Future.delayed(interval);
}
}
I have no problem running in my debug mode, but this error occurs in release mode. If it is not a component problem, please let me know.
@Wang-code-say can you provide a reproducible sample project?
@nmfisher Sorry, I just saw it. Here is an example I just created, thanks again for your reply https://github.com/Wang-code-say/flutter_test.git
@Wang-code-say can you provide a reproducible sample project?
hello ,waiting your response
You've added the @pragma('vm:entry-point')
annotation to the wrong function. It needs to be on the isolate entrypoint function passed to FlutterIsolate.spawn
(i.e. add it here https://github.com/Wang-code-say/flutter_test/blob/4ca5081b69b52dcfbd408620c62aeb4babe3c134/flutter_isolate_test/lib/main.dart#L131).
您已将
@pragma('vm:entry-point')
注释添加到错误的函数中。它需要定位传递到隔离入口点函数上FlutterIsolate.spawn
(即在此处添加它https://github.com/Wang-code-say/flutter_test/blob/4ca5081b69b52dcfbd408620c62aeb4babe3c134/flutter_isolate_test /lib/main.dart#L131)。
ok ,thank you so much ,it's working ,i will close this issu
E/flutter (19743): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value E/flutter (19743): #0 FlutterIsolate._isolateInitialize.. (package:flutter_isolate/flutter_isolate.dart:141)
E/flutter (19743): #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593)
E/flutter (19743): #2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339)
E/flutter (19743): #3 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271)
E/flutter (19743): #4 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774)
E/flutter (19743): #5 _StreamController._add (dart:async/stream_controller.dart:648)
E/flutter (19743): #6 _StreamController.add (dart:async/stream_controller.dart:596)
E/flutter (19743): #7 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192)
E/flutter (19743):
The above is the problem I encountered