ym_android_intent_plus

pub package pub points

Launch Android Intent objects from Flutter. The plugin supports explicit and implicit intents, chooser dialogs, URI intent strings, activity resolution, broadcasts, services, extras, MIME types, packages, and component names.

This package is Android-only. Calls are safe no-ops on other platforms.

Requirements

  • Flutter >=3.35.0
  • Dart >=3.9.0 <4.0.0
  • Android API 23+
  • Android compile SDK 36
  • Java 17
  • Android Gradle Plugin 8.13.0 / Gradle 8.14.5 for the included Android projects

Installation

Add the package to pubspec.yaml:

dependencies:
  ym_android_intent_plus: ^1.0.0

Then run flutter pub get.

Launch an intent

import 'package:ym_android_intent_plus/android_intent.dart';

final intent = AndroidIntent(
  action: 'android.intent.action.VIEW',
  data: 'https://flutter.dev',
);

await intent.launch();

action, data, category, type, package, and componentName map to their Android Intent equivalents. A component name must be used together with its package name.

Extras and arrays

Use arguments for normal extras and arrayArguments when the receiver requires an actual array (for example, email recipients):

final emailIntent = AndroidIntent(
  action: 'android.intent.action.SEND',
  type: 'message/rfc822',
  arguments: <String, dynamic>{
    'android.intent.extra.SUBJECT': 'Subject',
  },
  arrayArguments: <String, List<dynamic>>{
    'android.intent.extra.EMAIL': <String>['person@example.com'],
  },
);

await emailIntent.launch();

Supported scalar extras are strings, integers, doubles, booleans, and byte arrays. Lists in arguments are sent as Android ArrayList extras. Lists in arrayArguments are sent as typed Android arrays of strings, integers, or booleans.

Choosers, services, and broadcasts

await intent.launchChooser('Open with');

await AndroidIntent(action: 'com.example.SYNC').sendService();

await AndroidIntent(action: 'com.example.EVENT').sendBroadcast();

Starting a service may be restricted by Android background-execution rules. The receiving application is responsible for declaring the service or receiver and for any required permissions.

Parse an intent URI

await AndroidIntent.parseAndLaunch(
  'intent:#Intent;action=android.intent.action.VIEW;'
  'S.android.intent.extra.TEXT=Hello;end',
);

This uses Android's Intent.parseUri with Intent.URI_INTENT_SCHEME.

Query the resolving activity

final canOpen = await intent.canResolveActivity();
final activity = await intent.getResolvedActivity();

if (activity != null) {
  print('${activity.appName}: ${activity.activityName}');
}

On Android 11 and later, package visibility rules apply. If a query is not automatically visible, declare the matching <queries> entry in the host application's AndroidManifest.xml:

<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https" />
  </intent>
</queries>

See the Android package visibility documentation for more details.

Intent flags

Use constants from flag.dart:

import 'package:ym_android_intent_plus/flag.dart';

final intent = AndroidIntent(
  action: 'android.intent.action.VIEW',
  data: 'https://flutter.dev',
  flags: <int>[Flag.FLAG_ACTIVITY_NEW_TASK],
);

Development

Run package checks from the repository root:

flutter pub get
dart format .
flutter analyze
flutter test

The example directory contains a runnable demonstration and integration tests for Android behavior.

License

See LICENSE.

Libraries

android_intent
flag