android_multiple_identifier 1.0.2

  • Example
  • Installing
  • Versions
  • 83

android_multiple_identifier #

Exclusive for Android A plugin that provides multiple Android unique identifiers for you to choose the one that best applies to your needs. This plugin is aimed for projects that need to a unique identifier for Android devices and need multiple options to test in their applications:

  • ANDROID_ID usually works but it is known not to be 100% reliable.
  • IMEI code is unique for each device but only comes with devices that have telephony services. It is also not recommended for other than fraud prevention.
  • Serial Number is also unique for each device but it is only required for devices that do not have telephony services, so it is possible that some devices do not have a serial number (possible but very unlikely).

All there 3 options are provided so you can use the one that best applies to your needs (or maybe multiple options combined).

Permission READ_PHONE_STATE are required but the plugin has a method that takes care of that.

Getting Started #

Make sure you add the needed permission to your Android Manifest Permission and Info.plist.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />


Android #

Be sure to ask permissions first, otherwise, the app won't be able to get the IMEI code and Serial number:

await AndroidMultipleIdentifier.requestPermission();

Then you can call any of the three available methods:

String imei = await AndroidMultipleIdentifier.imeiCode;
String serial = await AndroidMultipleIdentifier.serialCode;
String androidID = await AndroidMultipleIdentifier.androidID;

Or call a map contaning the 3 values so you reduce the times you call native android:

Map idMap = await AndroidMultipleIdentifier.idMap;

String imei = idMap["imei"];
String serial = idMap["serial"];
String androidID = idMap["androidId"];

Android Permissions #

Besides the request permission method:

await AndroidMultipleIdentifier.requestPermission();

You can use methods for checking status of the permissions:

bool permissionStatus = await AndroidMultipleIdentifier.checkPermission(); // true if the permission is already granted
bool isPermissionRejected = await AndroidMultipleIdentifier.checkPermissionRationale(); // true if the user previously rejected the app
bool setToNeverAskAgain = AndroidMultipleIdentifier.neverAskAgain; //true if the user rejected the app and set to never ask again

For openning settings (and modifiying permissions manually):


Check Platform Version #

Just in case you need it:

platformVersion = await AndroidMultipleIdentifier.platformVersion;

iOS #

For now the iOs functionality has been disabled. The app won't crash on iOS if you add it to your pubspec.yaml file.

1.0.2 #

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

0.2.7 #

  • Added compatibility with other plugins that requests permissions.
  • Added license.

0.2.6 #

  • Added a method for opening the application settings screen.

0.2.5 #

  • Added a method for checking if the user check the "never ask again" box on permission request

0.2.4 #

  • Fixed bug on rationale method for android below api 26

0.2.1 - 0.2.3 #

  • updated and fixed instruccions

0.2.0 #

  • updated plugin info

0.1.10 #

  • Added functionality to api lower than 26.

0.1.9 #

  • Removed simple_permissions plugin, removed method channels for iOS
  • It's not compatible with iOS but it doesn't crash on iOS when added in the pubspec.yaml file

0.1.3 - 0.1.4 #

  • Added an idMap method that returns a map with all the id's

0.0.9 - 0.1.2 #

  • Fixed graddle dependencies issues for older versions.

0.0.2 #

  • Added Permission methods

0.0.1 #

  • Initial release.


import 'package:flutter/material.dart';
import 'package:android_multiple_identifier/android_multiple_identifier.dart';
import 'dart:async';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _imei = 'Unknown';
  String _serial = 'Unknown';
  String _androidID = 'Unknown';

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    String imei;
    String serial;
    String androidID;

    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await AndroidMultipleIdentifier.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';

    await AndroidMultipleIdentifier.requestPermission();

    try {
      imei = await AndroidMultipleIdentifier.imeiCode;
      serial = await AndroidMultipleIdentifier.serialCode;
      androidID = await AndroidMultipleIdentifier.androidID;
    } catch (e) {
      imei = 'Failed to get IMEI.';
      serial = 'Failed to get Serial Code.';
      androidID = 'Failed to get Android id.';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
      _imei = imei;
      _serial = serial;
      _androidID = androidID;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
            child: Column(
          children: <Widget>[
              '\nRunning on: $_platformVersion\n',
            Text('IMEI: $_imei\n'),
              'Serial Code: $_serial\n',
              'Android ID: $_androidID\n',

Use this package as a library

1. Depend on it

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

  android_multiple_identifier: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:android_multiple_identifier/android_multiple_identifier.dart';
Version Uploaded Documentation Archive
1.0.2 Mar 12, 2019 Go to the documentation of android_multiple_identifier 1.0.2 Download android_multiple_identifier 1.0.2 archive
1.0.1 Mar 12, 2019 Go to the documentation of android_multiple_identifier 1.0.1 Download android_multiple_identifier 1.0.1 archive
1.0.0 Mar 12, 2019 Go to the documentation of android_multiple_identifier 1.0.0 Download android_multiple_identifier 1.0.0 archive
0.2.7 Dec 31, 2018 Go to the documentation of android_multiple_identifier 0.2.7 Download android_multiple_identifier 0.2.7 archive
0.2.6 Dec 24, 2018 Go to the documentation of android_multiple_identifier 0.2.6 Download android_multiple_identifier 0.2.6 archive
0.2.5 Dec 21, 2018 Go to the documentation of android_multiple_identifier 0.2.5 Download android_multiple_identifier 0.2.5 archive
0.2.4 Dec 20, 2018 Go to the documentation of android_multiple_identifier 0.2.4 Download android_multiple_identifier 0.2.4 archive
0.2.3 Dec 19, 2018 Go to the documentation of android_multiple_identifier 0.2.3 Download android_multiple_identifier 0.2.3 archive
0.2.2 Dec 19, 2018 Go to the documentation of android_multiple_identifier 0.2.2 Download android_multiple_identifier 0.2.2 archive
0.2.1 Dec 19, 2018 Go to the documentation of android_multiple_identifier 0.2.1 Download android_multiple_identifier 0.2.1 archive

All 31 versions...

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 Apr 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

13 out of 13 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/android_multiple_identifier.dart.

Run flutter format to format lib/android_multiple_identifier.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8