Flutter get IMEI
To get the International Mobile Equipment Identity (IMEI) of a device in a Flutter application, you can use the flutter_imei package. This package provides a simple API to fetch the IMEI number of the device.
Step 1: Add dependency
To use the flutter_imei package, add it as a dependency in your pubspec.yaml file:
dependencies: flutter_imei: ^1.0.0
Step 2: Import the package
In the Dart file where you want to retrieve the IMEI number, import the flutter_imei package:
import 'package:flutter_imei/flutter_imei.dart';
Step 3: Get the IMEI number
Use the static method ‘getImeiMEID’ provided by the flutter_imei package to fetch the IMEI number:
String imei = await FlutterImei.getImeiMEID;
Example
Here’s an example to retrieve the IMEI number of a device:
import 'package:flutter/material.dart'; import 'package:flutter_imei/flutter_imei.dart'; void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State{ String imei = ''; @override void initState() { super.initState(); getIMEI(); } Future getIMEI() async { String imeiNumber = await FlutterImei.getImeiMEID; setState(() { imei = imeiNumber; }); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Get IMEI', home: Scaffold( appBar: AppBar( title: Text('Flutter Get IMEI'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'IMEI: $imei', style: TextStyle(fontSize: 18), ), ], ), ), ), ); } }
- Flutter format phone number
- Flutter floating action button position fixed
- Flutter firebase send notification to specific user
- Flutter get bottom navigation bar height
- Flutter expansiontile remove border
- Flutter fixed bottom container
- Flutter failed host lookup: (os error: no address associated with hostname, errno = 7)
- Flutter execution failed for task ‘:app:checkdebugaarmetadata’.
- Flutter file exists
- Flutter get device name