Created
February 8, 2021 13:18
-
-
Save lbarqueira/3183ee91814794ef5c898064b0399ad4 to your computer and use it in GitHub Desktop.
Flutter layout codelab, where you learn how to build a Flutter UI without downloading and installing Flutter or Dart! Row, Column, Flexible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Flutter Tutorial', | |
home: Scaffold( | |
body: Container( | |
decoration: BoxDecoration(color: Colors.cyan), | |
child: MyWidget(), | |
), | |
), | |
), | |
); | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
//mainAxisSize: MainAxisSize.max, | |
//mainAxisAlignment: MainAxisAlignment.spaceAround, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
//BlueBox(), | |
//BiggerBlueBox(), | |
BlueBox(), | |
Flexible( | |
fit: FlexFit.tight, | |
flex: 1, | |
child: BlueBox(), | |
), | |
Flexible( | |
fit: FlexFit.tight, | |
flex: 2, | |
child: BlueBox(), | |
), | |
], | |
); | |
} | |
} | |
class BlueBox extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: 50, | |
height: 50, | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
border: Border.all(), | |
), | |
); | |
} | |
} | |
class BiggerBlueBox extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: 50, | |
height: 100, | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
border: Border.all(), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment