You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a test to check if the library works
void main() async {
// WidgetsFlutterBinding.ensureInitialized();
test('library works with primitives', () async {
final isolates = IsolateHandler();
var completer = Completer();
// Set new count and display current count.
void setCounter(int counter) {
// We will no longer be needing the isolate, let's dispose of it.
isolates.kill("counter");
expectAsync0(() {
expect(counter, 1);
});
completer.complete();
}
isolates.spawn<int>(entryPoint,
name: "counter",
// Executed every time data is received from the spawned isolate.
onReceive: setCounter,
// Executed once when spawned isolate is ready for communication.
onInitialized: () => isolates.send(0, to: "counter"));
await completer.future;
});
}
void entryPoint(Map<String, dynamic> context) {
// Calling initialize from the entry point with the context is
// required if communication is desired. It returns a messenger which
// allows listening and sending information to the main isolate.
final messenger = HandledIsolate.initialize(context);
// Triggered every time data is received from the main isolate.
messenger.listen((req) {
// Add one to the count and send the new value back to the main
// isolate.
if (req is int) {
messenger.send(req++);
}
});
}
If I don't initialize widgets binding, I get Null check operator used on a null value
And If I uncomment that line, I get MissingPluginException(No implementation found for method spawn_isolate on channel com.rmawatson.flutterisolate/control)
How to run this library inside tests?
The text was updated successfully, but these errors were encountered:
No. I'm not an avid fan of such testing in cases like this (there are cases where things can be tested easily but I don't think this is one of them). If you can come up with a testing scenario that works and can be added, all right, but I'm unlikely to take any steps to add it myself. I'm not even sure a test environment works the same as the real one--don't forget, the main idea of flutter_isolate is to instantiate an extra Flutter engine in the first place.
I am trying to write a test to check if the library works
If I don't initialize widgets binding, I get
Null check operator used on a null value
And If I uncomment that line, I get
MissingPluginException(No implementation found for method spawn_isolate on channel com.rmawatson.flutterisolate/control)
How to run this library inside tests?
The text was updated successfully, but these errors were encountered: