intent 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

intent #

A simple flutter plugin to deal with Android Intents, written with ❤️.

Show some ❤️ by putting ⭐

intent tries to help you in launching another android activity using Android Intents. This Dart API replicates Android Intent API, so for detailed information on how to use it efficiently, when to send what kind of data, you may be interested in taking a look here. Which explains things more elaborately.

intent is readily available for use.

what does it do ? #

  • intent is your one stop solution for handling different Android Intents from Flutter app.
  • It provides an easy to use Dart API, which can be used to launch different kind of Android Activities
  • You can view / create documents
  • Pick document(s) from Document Tree
  • Open default Assist Activity
  • Perform a Web Search
  • Request definition of a certain string to default Assist Activity
  • Open image for editing / viewing
  • Share text / multimedia to another activity
  • Send Email to specific user, while also setting CC & BCC
  • Share multiple documents at a time
  • Sync system content
  • Translate text
  • Set Wallpaper
  • Open any URL
  • Open Dialer for calling a specific number
  • Can pick a contact from your default phone activity
  • Can capture a photo using default Camera Activity

how to use it ? #

Well make sure, you include intent in your pubspec.yaml.

Define a Term : #

        ..putExtra(Extra.EXTRA_TEXT, "json")
        ..startActivity().catchError((e) => print(e));

Show Desired Application Info : #

Make sure you address app using its unique package id.

        ..putExtra(Extra.EXTRA_PACKAGE_NAME, "com.whatsapp")
        ..startActivity().catchError((e) => print(e));

Show Application Preference Activity : #

        ..startActivity().catchError((e) => print(e));

Launch Application Error Reporting Activity : #

        ..startActivity().catchError((e) => print(e));

Launch Default Assist Activity : #

        ..startActivity().catchError((e) => print(e));

Report Bug : #

        ..startActivity().catchError((e) => print(e));

View a URI : #

Which activity to be launched, depends upon type of URI passed.

In case of passing tel URI, opens dialer up.

        ..setData(Uri(scheme: "tel", path: "123"))
        ..startActivity().catchError((e) => print(e));

If you pass a mailto URI, it'll open email app.

        ..setData(Uri(scheme: "mailto", path: ""))
        ..startActivity().catchError((e) => print(e));

In case of http/ https URI, opens browser up.

        ..setData(Uri(scheme: "https", host:""))
        ..startActivity().catchError((e) => print(e));

Dial a Number using Default Dial Activity : #

Setting data using tel URI, will open dialer, number as input.

        ..setData(Uri(scheme: 'tel', path: '121'))
        ..startActivity().catchError((e) => print(e));

But if you're interested in opening dialer without any numbers dialer, make sure you don't set data field.

        ..startActivity().catchError((e) => print(e));

Calling a Number : #

You can simply call a number, but make sure you've necessary permissions to do so.

        ..setData(Uri(scheme: 'tel', path: '121'))
        ..startActivity().catchError((e) => print(e));

It'll always be a wise decision to use ACTION_DIAL, because that won't require any kind of permissions.

Create a Document : #

Content type of document is set text/plain, category is CATEGORY_OPENABLE and file name is passed as an extra i.e. EXTRA_TITLE.

        ..putExtra(Extra.EXTRA_TITLE, "test.txt")
        ..startActivity().catchError((e) => print(e));

You can also set path of file using data field. But make sure data field is a valid path URI.

Edit Document : #

You can edit image/ text or any other kind of data using appropriate activity.

        ..setData(Uri(scheme: 'content',
        ..startActivity().catchError((e) => print(e));

Add a Contact to your Contact Database : #

        ..setData(Uri(scheme: 'tel', path: '1234567890'))
        ..startActivity().catchError((e) => print(e));

Search for a Term : #

Opens up a list of eligible candidates, which can provides search activity.

        ..putExtra(Extra.EXTRA_TEXT, 'json')
        ..startActivity().catchError((e) => print(e));

Share Text/ Media : #

Make sure you've set appropriate path URI for sharing documents/ media using EXTRA_STREAM and also set type properly.

Following one will share a plain text. For sharing html formatted text, set type to text/html.

        ..putExtra(Extra.EXTRA_TEXT, 'json')
        ..startActivity().catchError((e) => print(e));

But if you're interested in creating a chooser i.e. all eligible candidates shown up system, which can handle this intent, make sure you set createChooser named parameter to true, which is by default false.

Send Email to certain ID while setting Content and CC/ BCC : #

        ..setData(Uri(scheme: 'mailto', path: ''))
        ..putExtra(Extra.EXTRA_CC, [''])
        ..putExtra(Extra.EXTRA_TEXT, 'Hello World')
        ..startActivity().catchError((e) => print(e));

Translate a Text using default Assist Activity : #

        ..putExtra(Extra.EXTRA_TEXT, "I Love Computers")
        ..startActivity().catchError((e) => print(e));

Pick a Contact up from Phone : #

  • Opens default Phone Activity and let user pick a contact up, selected contact will be returned as Future<List<String>> from startActivityForResult().
                ..startActivityForResult().then((data) => print(data),
                onError: (e) => print(e));

Capture Image using default Camera activity : #

Path to captured image can be grabbed from Intent().startActivityForResult().then(() { ... } ), which will be provided in form of List<String>, open file using that path, File(data[0]). Now you can work on that image file.

                ..startActivityForResult().then((data) => print(data[0]), // gets you path to image captured
                onError: (e) => print(e));


If you're not interested in showing default activity launch animation, set following flag.


If you don't want this activity to be displayed in recents, set following flag.


If you request for certain Activity and no eligible candidate was found, you'll receive one error message, which you can listen for using Future.catchError((e) {},) method.

PlatformException(Error, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SYSTEM_TUTORIAL }, null)

Currently a limited number of Actions are provided in Action class, but you can always use a string constant as an Action, which will help you in dealing with many more Activities.

Hoping this helps 😉

1.0.0 #

  • intent is your one stop solution for handling different Android Intents from Flutter app.

Enjoy :)

1.1.0 #

  • intent - your one stop solution for android activity, can now get you back result from launched activity
  • Can pick documents/ multimedia using their default activity, and get you back a List<String>, which holds result.
  • There might be some situation in which you want to pick multiple documents, which is why Intent.startActivityForResult() returns a List<String>.
  • Most important news, intent can capture image using default Camera Activity and get you back path to captured image.


intent_example #

Demonstrates how to use the intent plugin.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  intent: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:intent/intent.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies