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