SonerB
SonerB

Reputation: 41

How can ı get the Device İnformation on my Flutter app?

hi guys i want to show my device model inside my flutter app. I used device_info_plus package but it didn't work. How can I do that?

Upvotes: 0

Views: 1984

Answers (2)

rajdeep shah
rajdeep shah

Reputation: 49

As of now please use this package:

dependencies:
      flutter:
        sdk: flutter
      device_info_plus: ^4.0.1

Link: https://pub.dev/packages/device_info_plus

Upvotes: 2

patricher
patricher

Reputation: 44

Into your pubspec.yaml add the device_info package:

    dependencies:
      flutter:
        sdk: flutter
      device_info: ^2.0.3

in your dart code just add this and will see device information:

  import 'package:device_info/device_info.dart';


  showInfoDevice(){
    String deviceInfo;
    if (Platform.isIOS) {
        IosDeviceInfo iosInfo =
            await DeviceInfoPlugin().iosInfo;
        deviceInfo = iosInfo.utsname.machine;
    } else {
      AndroidDeviceInfo androidInfo =
          await DeviceInfoPlugin()
               .androidInfo;
      deviceInfo = androidInfo.model;
    }
    print(deviceInfo);
 }
 
 void initState(){
      super.initState();
      showInfoDevice();
 }

Upvotes: 2

Related Questions