Solution: Measure your Sizes - Responsive UI Widgets

Find the solution to the last challenge using the MediaQuery and LayoutBuilder widgets.

In this lesson, we provide two solutions to the previous challenge. The first one uses MediaQuery, and the second one uses LayoutBuilder. It’s possible to use other widgets to achieve the same result, but in this lesson, we focus on MediaQuery and LayoutBuilder.

Solution using MediaQuery

To change the layout depending on the screen size by using MediaQuery, we need to retrieve MediaQueryData in the build method. Once we have that, we use the screen width to calculate whether there’s enough horizontal space to fit two images…

Get hands-on with 1400+ tech skills courses.