Let me explain to you this by device_info plugin.
Step 1
Add Dependency
dependencies:
flutter:
sdk: flutter
device_info: ^0.4.0+1
Step 2
Import your file at the beginning
import 'package:device_info/device_info.dart';
Step 3
Create an async function to return device id.
deviceInfo() async{
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return androidInfo.id;
}
Step 4
Create a FutureBuilder() to display device id or perform any action.
FutureBuilder(
future: deviceInfo(),
builder: (BuildContext context, AsyncSnapshot snap){
// do nothing...
if (snap.hasData){
//your logic goes here.
}else {
return new CircularProgressIndicator();
}
},
)