Labs ICT
⭐ Pro Login

Responsive Layouts

Adapting to different screen sizes.

1 min read | Flutter Tutorial
⭐

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Responsive Layouts

MediaQuery gives you screen size information. LayoutBuilder lets you build different layouts based on available space. Expanded and Flexible help widgets fill available space. You can show different layouts for narrow and wide screens.

LayoutBuilder(
  builder: (context, constraints) {
    if (constraints.maxWidth > 600) {
      return Row(
        children: [
          Expanded(child: Text('Wide screen')),
          Expanded(child: Text('Two columns')),
        ],
      );
    } else {
      return Column(
        children: [
          Text('Narrow screen'),
          Text('One column'),
        ],
      );
    }
  },
)