0

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:

output obs.: first question here, so sorry if something is wrong.

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? Commented 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. Commented Aug 9, 2021 at 3:24
  • Can you share your code for your device info Commented Aug 9, 2021 at 4:14
  • Try pub.dev/packages/device_name or pub.dev/packages/device_information Commented 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" Commented Aug 9, 2021 at 13:01

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

i just tried it but it contains basically the same information that device_info package (for android at least) as shown in this print.
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
@NickN I can't find the device name on android, where did you find it?
@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. ;-)
0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.