Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Limit width of application to biggest phone

Tags:

flutter

We have a phone application and wish to release to tablets as well, but we want to limit the app on tablet to look like on a biggest phone. Just width would be fine.

Is there an option to limit the screen size for the entire app? Also, when I call MediaQuery size.width is that dpi or pixels or what?

It seems to me that I would have to go to everyscreen and put them in a container with max width but I was interested in other options.

This is all for Flutter.

like image 494
Nemanja Nisic Avatar asked Dec 21 '25 20:12

Nemanja Nisic


1 Answers

If you want to limit your app to fixed max width, you could simply wrap the material app inside container with fixed max width.

Example

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        constraints: const BoxConstraints(maxWidth: 700),
        child: MaterialApp(
                title: "Fixed width app"
            ),
      ),
    );
  }
}
like image 71
suzan Avatar answered Dec 23 '25 10:12

suzan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!