Advertisement
AbiMulya

Flexible Widget

Oct 7th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.62 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatelessWidget {
  8.   // This widget is the root of your application.
  9.   @override
  10.   Widget build(BuildContext context) {
  11.     return MaterialApp(
  12.       home: Scaffold(
  13.         appBar: AppBar(
  14.           title: Text("Flexible Layout"),
  15.         ),
  16.         body: Column(
  17.           children: <Widget>[
  18.             Flexible(
  19.               child: Row(
  20.                 children: <Widget>[
  21.                   Flexible(
  22.                       flex: 1,
  23.                       child: Container(
  24.                         margin: EdgeInsets.all(5),
  25.                         color: Colors.red,
  26.                       )),
  27.                   Flexible(
  28.                       flex: 1,
  29.                       child: Container(
  30.                         margin: EdgeInsets.all(5),
  31.                         color: Colors.green,
  32.                       )),
  33.                   Flexible(
  34.                       flex: 1,
  35.                       child: Container(
  36.                         margin: EdgeInsets.all(5),
  37.                         color: Colors.purple,
  38.                       ))
  39.                 ],
  40.               ),
  41.             ),
  42.             Flexible(
  43.                 flex: 2,
  44.                 child: Container(
  45.                   margin: EdgeInsets.all(5),
  46.                   color: Colors.amber,
  47.                 )),
  48.             Flexible(
  49.                 flex: 1,
  50.                 child: Container(
  51.                   margin: EdgeInsets.all(5),
  52.                   color: Colors.blue,
  53.                 ))
  54.           ],
  55.         ),
  56.       ),
  57.     );
  58.   }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement