setBackgroundHandlerRaw method

  1. @override
Future<MapxusMethodResponse> setBackgroundHandlerRaw({
  1. required int dispatcherHandle,
  2. required int userCallbackHandle,
})
override

Stores the raw Dart callback handles on the native side so the foreground service can start a headless Flutter engine when the app is closed.

Implementation

@override
Future<MapxusMethodResponse> setBackgroundHandlerRaw({
  required int dispatcherHandle,
  required int userCallbackHandle,
}) async {
  try {
    final result = await _channel.invokeMethod<Map<dynamic, dynamic>>(
      'setBackgroundHandler',
      {
        'dispatcherHandle': dispatcherHandle,
        'userCallbackHandle': userCallbackHandle,
      },
    );
    return MapxusMethodResponse.fromMap({
      'success': result?['success'] ?? false,
      'message': result?['message'] ?? 'Unknown error',
    });
  } catch (e) {
    return MapxusMethodResponse.fromMap({
      'success': false,
      'message': e.toString(),
    });
  }
}