Last active
February 8, 2021 17:01
-
-
Save lbarqueira/bb99466d5bf15402bfcb75d2a6f2ae9c 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, SizedBox, Spacer
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(), | |
Spacer( | |
flex: 1, | |
), | |
SizedBox( | |
child: BlueBox(), | |
width: 100, | |
height: 100, | |
), | |
//SizedBox( | |
// width: 100, | |
//), | |
Spacer( | |
flex: 1, | |
), | |
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