callIntent method

Future<void> callIntent({
  1. required String intentType,
  2. Uri? uri,
  3. Map<String, dynamic>? extras = const {},
  4. String? mimeType,
})

usage call -> AndroidIntents.ACTION_DIAL

//Call Phone Dialer
await ThanPkg.android.intent.callIntent(
  intentType: AndroidIntents.ACTION_DIAL,
  uri: Uri.parse('tel:[number]'),
);

//Call Other App
await ThanPkg.android.intent.callIntent(
  intentType: AndroidIntents.ACTION_VIEW,
  uri: Uri.parse('https://github.com/'),
);
// Share
await ThanPkg.android.intent.callIntent(
  intentType: AndroidIntentData.ACTION_SEND,
  extras: {
    AndroidIntentData.EXTRA_TEXT: "Hello World",
    AndroidIntentData.EXTRA_SUBJECT: "Subject Example",
  },
  mimeType: "text/plain", // important
);

Implementation

Future<void> callIntent({
  required String intentType,
  Uri? uri,
  Map<String, dynamic>? extras = const {},
  String? mimeType,
}) async {
  Map<String, dynamic> map = {'intentType': intentType};
  if (uri != null) {
    map['uriString'] = uri.toString();
  }
  if (extras != null) {
    map['extras'] = extras;
  }
  if (mimeType != null) {
    map['mime'] = mimeType;
  }
  await _channel.invokeMethod('$_name/callIntent', map);
}