US Office

1176 Shadeville Rd, Crawfordville Florida 32327, USA

 +1 (850) 780-1313

India Office

Office No 405, Kabir Shilp, Opp. Kansar Hotel, Opp. Landmark, Kudasan, Gandhinagar, Gujarat 382421

[email protected]

What’s the Difference Between Double.Infinity and MediaQuery In Flutter?

What's the Difference Between Double.Infinity and MediaQuery In Flutter

What’s the Difference Between Double.Infinity and MediaQuery In Flutter?

The scaffold is like a parent widget or just consider a whole where you would have different properties like app bar, body all those type widgets are child widget scaffold gives better look to the app where only using a container is much. So in today’s article, we will go through what’s the difference between Double.Infinity and MediaQuery In Flutter?

The difference can be summarized into:

  • I want to be as big as my parent allows double.infinity
  • I want to be as big as the screen MediaQuery.

Usually, you’ll want to use double.infinity, but it’s not always possible. Some widgets allow their children to be as big as they want to be column widget, ListView widget, OverflowBox… in that situation using double. infinity creates a paradox:

  • The parent allows any size
  • The child wants the biggest size allowed by the parent

Using MediaQuery in these situations is bad though.

You will rarely want to do that unless you’re creating a widget similar to Scaffold.

That’s where widgets such as IntrinsincHeight comes in handy.

These widgets are able to solve the paradox, and therefore have a valid layout.

Conclusion:

Thanks for Reading !!!

In this article, we have been through what’s the difference between Double.Infinity and MediaQuery in flutter?

Do let us know if you need any assistance with flutter development. We would love to assist you.

Also, check the article for Making Button Expand to the Size of its Parent?

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Comments
  • October 3, 2021

    Great article!! Really appreciate your effort!

    reply
Post a Comment