How do I check if a device is an emulator or a physical device?

0

Issue

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.

Solution

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}'); 

Answered By – Midhun MP

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More