rmawatson/flutter_isolate

Unhandled Exception: Null check operator used on a null value

Closed this issue · 2 comments

Is it support platform channel code in secondary isolate?

compute function also getting this error. and also pure isolate without this plugin, that way also getting the same error.

class NotificationCountService {
  static const platform = MethodChannel('com.yellochat.dev/notificationCount');

  static Future<void> setCountCompute(int count) async {
      FlutterIsolate.spawn(isolate1, count);
     // this is working without any issue isolate1(count);
  }
  
  static void isolate1(int count) async {
    var result = await platform.invokeMethod('setCount', {'count': count});
  }
}

Error

Unhandled Exception: Null check operator used on a null value
FlutterIsolate._isolateInitialize.<anonymous closure>.<anonymous closure> (package:flutter_isolate/flutter_isolate.dart:127:64)
 _rootRunUnary (dart:async/zone.dart:1370:13)
 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
_CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
_StreamController._add (dart:async/stream_controller.dart:607:7)
_StreamController.add (dart:async/stream_controller.dart:554:5)
_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

There shouldn't be any problem with platform channel methods. The error message you provided suggests that the Dart entrypoint can't be found (nothing to do with the platform channel), but the code snippet you pasted looks correct.

Can you please provide a link to a repository that fully reproduces your problem?

@bhanuka96 will close unless response received in 7 days.