So, I'm developing a monitoring app for android that support multiple devices, and I would like to get the device's name. I've already googled about this, with no success. Already tried the device_info package, but it doesn't have the information I need. Which is the following shown in the image:
6
-
Can you add a list that you like to get? The thing is, I don't understand image's language. You also like to get IMEI number?Md. Yeasin Sheikh– Md. Yeasin Sheikh2021-08-09 02:58:57 +00:00Commented Aug 9, 2021 at 2:58
-
the information i want of the image is the "ASUSZENFONE4", on android 9 that info are in Configuration -> System -> About Phone -> Device Name. I would also like to get the IMEI number, but didn't look into it yet.Samuel Juliano– Samuel Juliano2021-08-09 03:24:52 +00:00Commented Aug 9, 2021 at 3:24
-
Can you share your code for your device infoRavindra S. Patil– Ravindra S. Patil2021-08-09 04:14:22 +00:00Commented Aug 9, 2021 at 4:14
-
Try pub.dev/packages/device_name or pub.dev/packages/device_informationGursewak Singh– Gursewak Singh2021-08-09 04:51:42 +00:00Commented Aug 9, 2021 at 4:51
-
wrote this to show what i'm using of device_info androidInfo.device;androidInfo.model; androidInfo.product; ` the result are respectively, "ASUS_Z01KD_2", "ASUS_Z01KD", "WW_Z01KD"Samuel Juliano– Samuel Juliano2021-08-09 13:01:13 +00:00Commented Aug 9, 2021 at 13:01
|
Show 1 more comment
2 Answers
You can use device_info_plus, it is provided by fluttercommunity.dev and supports almost all platforms. You can check this API reference to get information based on platforms.
4 Comments
Samuel Juliano
i just tried it but it contains basically the same information that device_info package (for android at least) as shown in this print.
Nick N
Look at the example that's provided on their page. It contains many additional fields (including device name). Just include the widget into your app and view all of the fields. It's a comprehensive library that's been standardized by fluttercommunity.dev pub.dev/packages/device_info_plus/example
Myzel394
@NickN I can't find the device name on android, where did you find it?
Nick N
@Myzel394 try this one from dart io.
Platform.localHostname. that might work, I just used it the other day for something. But if using iOS, the App Store approval gods may not like it. ;-)Settings.Global.getString(contentResolver, Settings.Global.DEVICE_NAME)
Returns the name that was given to the device via device settings. Only available on Android 7.1+ (N_MR1). This name is seen when connecting to Bluetooth or wifi network. Using platform channels I delegated this name to Flutter side:
@RequiresApi(Build.VERSION_CODES.N_MR1)
private fun getDeviceName(): String {
return Settings.Global.getString(contentResolver, Settings.Global.DEVICE_NAME)
}
And then just call this method using PlatformChannels via Flutter.
