Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if flutter is running in simulator

Tags:

flutter

Is there a call to determine if flutter is running within a simulator or a physical device?

I am scanning QR codes, and want to bypass, since the camera is unavailable.

I expected to find this in platform.dart[1] but it's not there.

[1]https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/foundation/platform.dart

I imagine I can create a plugin if I really need, I'm hoping it already exists.

like image 935
Daniel Brotherston Avatar asked Apr 16 '18 20:04

Daniel Brotherston


People also ask

What is simulator in flutter?

A simulation models an object, in a one-dimensional space, on which particular forces are being applied, and exposes: The object's position, x. The object's velocity, dx. Whether the simulation is "done", isDone.

How do you add a simulator in flutter?

Creating Connection Choose Device: Open your VS Code and from the bottom right corner of your home screen click on the Flutter Device option. Select Device: When you click on the Flutter Device icon, list of available devices will open up in the command palette. Select the emulator you just created.

Can t run Flutter in Android Studio?

If you haven't run your Flutter app yet, you might see Android Studio report a build error when you open the android project. Run flutter pub get in the app's root directory and rebuild the project by selecting Build > Make to fix it.


1 Answers

Using the device info plus plugin you can get various information about the device you're running on, including 'isPhysicalDevice' for both Android and iOS (although you'll have to read them independently).

like image 135
rmtmckenzie Avatar answered Sep 18 '22 13:09

rmtmckenzie