Search code examples
androidfluttersizeflutter-dependenciesresponsive

Is there a way that Flutter won't allow my app to install or run at different sizes?


I have coded an application that I have only optimized for the size of the phone (it is responsive on the phone). Now I want it not to be run or installed when the user runs it with the emulator on the computer?! is there a way I have made my software responsive with package sizer.

I did this so that the software does not rotate, But I don't know how to make it display only for android resolution.

void main() {

  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations(
    [
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ],
  );

  runApp(const MyApp());
}

Solution

  • You can check the device height / width / resolution at runtime using MediaQuery. If the current device's resolution is not as per your app's preference you can show some alert message to the user like :

    App is only optimized for mobile devices

    And upon closing the modal exit the app programmatically using exit(0)

    Just for reference Flutter how to programmatically exit the app