android_multiple_identifier 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 92

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.3 #

  • Added try catch to succes() method to avoid IllegalStateException

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';
  Map _idMap = Map();

  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;
    Map idMap;

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

    bool requestResponse = await AndroidMultipleIdentifier.requestPermission();
    print("NEVER ASK AGAIN SET TO: ${AndroidMultipleIdentifier.neverAskAgain}");

    try {
      // imei = await AndroidMultipleIdentifier.imeiCode;
      // serial = await AndroidMultipleIdentifier.serialCode;
      // androidID = await AndroidMultipleIdentifier.androidID;
      idMap = await AndroidMultipleIdentifier.idMap;

    } catch (e) {
      idMap = Map();
      idMap["imei"] = 'Failed to get IMEI.';
      idMap["serial"] = 'Failed to get Serial Code.';
      idMap["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;
      _idMap = idMap;
      _imei = _idMap["imei"];
      _serial = _idMap["serial"];
      _androidID = _idMap["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',
            RaisedButton(child: Text('openSettings'),
            onPressed: () async {

Use this package as a library

1. Depend on it

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

  android_multiple_identifier: ^1.0.3

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:android_multiple_identifier/android_multiple_identifier.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 Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:android_multiple_identifier/android_multiple_identifier.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:android_multiple_identifier/android_multiple_identifier.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:android_multiple_identifier/android_multiple_identifier.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:android_multiple_identifier/android_multiple_identifier.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [android_multiple_identifier] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 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.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8