Flutter: How do I get the serial number of the device?

1.3k Views Asked by At

I'm using Flutter and the device_info_plus package. I made sure to add this permission in the manifest, but it still doesn't work:

<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
        tools:ignore="ProtectedPermissions" /> 

The code:

final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.deviceInfo;
final serialNumber = deviceInfo.data['serialNumber']; //Returns "unknown"
0

There are 0 best solutions below