Created
September 30, 2019 12:35
-
-
Save emisjerry/cfc854300d0d710521d1b874e57ef592 to your computer and use it in GitHub Desktop.
Container, shape and Expanded
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(home: MyApp())); | |
} | |
void pn(num n) => print(n); | |
// Column -> container | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
Widget scaffold = Scaffold( | |
appBar: AppBar(title: Text("My App")), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
// crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
Expanded( | |
flex: 2, | |
child: Container( | |
width: 100.0, | |
height: 100.0, | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
shape: BoxShape.rectangle, | |
), | |
alignment: Alignment.center, | |
// child的對齊 | |
child: Icon(Icons.home, color: Colors.white), | |
), | |
), | |
Expanded( | |
child: Container( | |
width: 100.0, | |
height: 100.0, | |
margin: EdgeInsets.only(top: 10), | |
decoration: BoxDecoration( | |
color: Colors.green, | |
shape: BoxShape.rectangle, | |
), | |
alignment: Alignment.center, | |
// child的對齊 | |
child: Icon(Icons.keyboard, color: Colors.white), | |
), | |
), | |
Container( | |
width: 100.0, | |
height: 100.0, | |
margin: EdgeInsets.only(top: 10), | |
decoration: BoxDecoration( | |
color: Colors.red, | |
shape: BoxShape.circle, | |
), | |
alignment: Alignment.center, | |
// child的對齊 | |
child: Icon(Icons.schedule, color: Colors.white), | |
), | |
], | |
), | |
), | |
); | |
return scaffold; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment