How to make a column that fit all the screen in Flutter
4,954
There you go
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Expanded(child: Container(color: Colors.blue)),
Expanded(child: Container(color: Colors.lightBlueAccent))
],
);
}
}
How it is done:
- I am running an app via the runApp method
- I create a column and place essentially containers with the colours in it
- But the containers don't have any size, so they are not visible
- With the expanded widget I let a widget know to be as big as possible.
- As I have two expanded widgets, they have the same size.
Voila
Screenshot from emulator device
Author by
Rémy Menard
Updated on December 10, 2022Comments
-
Rémy Menard over 1 year
I am starting flutter but I cannot figure out how to divide by 2 a column widget and make it fit all the screen as shown in the picture.