launchIntent method

  1. @override
Future<Map?> launchIntent({
  1. required FlutterIntentWithResult intentDetails,
  2. dynamic onResponse(
    1. dynamic
    )?,
  3. String? packageName,
})
override

Implementation

@override
Future<Map?> launchIntent(
    {required FlutterIntentWithResult intentDetails,
    Function(dynamic)? onResponse,
    String? packageName}) async {
  if (onResponse != null) {
    _startListeningToIntentStatus(onResponse);
  }
  try {
    Map? nativeResponse = await methodChannel.invokeMapMethod(
      methodName,
      {
        "intentURL": intentDetails.url,
        "action": intentDetails.action,
        "packageName": packageName,
        "extras": intentDetails.extras,
        "requestCode": intentDetails.requestCode,
      },
    );
    bool isSuccess = ((nativeResponse?["status"] ?? "") == "SUCCESS");
    if (!isSuccess) {
      _intentStatusSubscription?.cancel();
    }
    return nativeResponse;
  } catch (e) {
    // print the error
    rethrow;
  }
}