2

I want to know if there is any way to find whether the device is an emulator or a physical device.

I don't want my app to be installed on an emulator.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Roxx
  • 3,738
  • 20
  • 92
  • 155

3 Answers3

2

You can use flutter_is_emulator to identify emulator or simulator.

bool isAnEmulator = await FlutterIsEmulator.isDeviceAnEmulatorOrASimulator;

Inorder this to work, you need to install the app to the emulator/simulator first.

You can also use another popular flutter package device_info to do this.

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Is emulator: ${androidInfo.isPhysicalDevice}');

IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
print('Is simulator: ${iosInfo.isPhysicalDevice}'); 
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • Wow. I wasn't expecting that quick reply. I thought this will closed or downvoted. I will try and provide detailed answer for this question. Thanks for understanding the question. Voted up. – Roxx Apr 28 '20 at 09:29
  • 1
    @Ironic You are welcome, also check the updated answer. I've included one more plugin – Midhun MP Apr 28 '20 at 09:34
  • 1
    Thanks @Midhun I am sure it will help others too. This is general scenario. – Roxx Apr 28 '20 at 09:35
  • I have raised one question in the morning. if you have time have a look. https://stackoverflow.com/questions/61472420/flutter-e-location-permissions-4794-flutter-result-object-is-null – Roxx Apr 28 '20 at 09:53
  • I didn't find isPhysicalDevice in DeviceInfo plugin. – Roxx Apr 29 '20 at 06:24
  • Thanks. I will try and let you know. Just for understanding what is ;G (4). – Roxx Apr 29 '20 at 06:39
  • @Ironic That was a typo, please check and let me know if you face any issues :) – Midhun MP Apr 29 '20 at 06:41
1

Use trust_fall

trust_fall has following checks :

Checks whether device JailBroken on iOS/Android?

bool isJailBroken = await TrustFall.isJailBroken;

Checks whether device is real or emulator

bool isRealDevice = await TrustFall.isRealDevice;

Can this device mock location - no need to root!

bool canMockLocation = await TrustFall.canMockLocation;

(ANDROID ONLY) Check if application is running on external storage

bool isOnExternalStorage = await TrustFall.isOnExternalStorage; Check if device violates any of the above

bool isTrustFall = await TrustFall.isTrustFall;
Dhanaji Yadav
  • 1,202
  • 1
  • 14
  • 22
Sagar
  • 11
  • 2
1

Today will device_info_plus to get info

    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    print('Is emulator: ${androidInfo.isPhysicalDevice}');
    
    IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
    print('Is simulator: ${iosInfo.isPhysicalDevice}');
Matias de Andrea
  • 194
  • 2
  • 11