Cross-Platform Mobile Apps with Flutter

Responsive Design

Maximiliano Firtman

Maximiliano Firtman

Independent Consultant
Cross-Platform Mobile Apps with Flutter

Check out a free preview of the full Cross-Platform Mobile Apps with Flutter course

The "Responsive Design" Lesson is part of the full, Cross-Platform Mobile Apps with Flutter course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano demonstrates how Flutter handles responsive design. Media queries can be used to return different layout widgets depending on the size of the screen. Other containers, like the Wrap widget, can tile widgets to fit the screen.


Transcript from the "Responsive Design" Lesson

>> But before actually compiling the app, let's say you're going to create a website, a web app. What happens with responsive design? Look at that. It doesn't look like really nice, right? So it's like, really big. So how responsive design works with Flutter? There are many ways to solve the responsive design problem.

Let me go back to the initial view. For example, if I'm going to the offers page, one way to work is to create the property with a media query similar to browser media queries. So for example, if we want this screen size, we can say MediaQuery of the context we receive.

And we can query about a lot of stuff, devicePixelRatio, gestureSetting, and we have size, okay? So this is the size of the screen. So actually, I can make conditions here. If the width of the screen is more than 500, then I'm going to return this view. If not, I'm going to return that view.

Yeah, you need to do this manually, right? But then you can have a large viewport and a small viewport with media queries. Also, the other way, sometimes instead of using a ListView, for example, there is another word called wrap. Wrap would actually make the trick pretty simply. So if I go to offers now, wrap, what we'll do is we'll try to wrap the elements.

So maybe what I need is to also fix the offers, Not just in the height, but also in the width. By 300. Have a typo. So if I go to offers now, the wrap widget would actually try to wrap the elements if there is no space, okay? Well, then you can center, you can play with this, but wrap would actually work like float in HTML, okay?

So with media queries and wrap, you can start making decisions about your user interface.
>> I haven't used this kinda implementation, but in other projects, I used the inits, one of the lifecycle hooks to grab the data versus using the-
>> Futures.
>> Yeah, so just something, a different style.

>> No, the thing is that Flutter had different versions, and also Dart had different versions. So if you have been doing Flutter since the beginning, maybe you're not using all the techniques that we've seen today because they were added over time, okay? So there are many things that were added over time, so maybe that's why you are using that technique.

Also, maybe because you are using a different design pattern. So typically today, we prefer futures that the future builder will actually help you a lot to work with async programming.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now