Created
February 15, 2020 16:33
-
-
Save ryanlid/dfe293099ca7e967dc9f6cc7022c4954 to your computer and use it in GitHub Desktop.
Container 容器布局
This file contains 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( | |
title: "Container 容器布局", | |
home: LayoutDemo(), | |
)); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
Widget container = Container( | |
decoration: BoxDecoration( | |
color: Colors.grey, | |
), | |
child: Column( | |
children: <Widget>[ | |
Row( | |
children: <Widget>[ | |
Expanded( | |
child: Container( | |
width: 150.0, | |
height: 150.0, | |
decoration: BoxDecoration( | |
border: Border.all(width: 10.0, color: Colors.blueGrey), | |
), | |
margin: const EdgeInsets.all(4.0), | |
child: Image.network( | |
"https://static.lidong.me/upload/XjGwvaVAI.png"), | |
), | |
), | |
Expanded( | |
child: Container( | |
width: 150.0, | |
height: 150.0, | |
decoration: BoxDecoration( | |
border: Border.all( | |
width: 10.0, | |
color: Colors.blueGrey, | |
), | |
), | |
child: Image.network( | |
"https://static.lidong.me/upload/c7QdErvcb.png"), | |
), | |
) | |
], | |
), | |
Row( | |
children: <Widget>[ | |
Expanded( | |
child: Container( | |
width: 150.0, | |
height: 150.0, | |
decoration: BoxDecoration( | |
border: Border.all(width: 10.0, color: Colors.blueGrey), | |
borderRadius: BorderRadius.all(Radius.circular(8.0)), | |
), | |
margin: EdgeInsets.all(4.0), | |
child: Image.network( | |
"https://static.lidong.me/upload/c7QdErvcb.png"), | |
), | |
), | |
Expanded( | |
child: Container( | |
width: 150.0, | |
height: 150.0, | |
decoration: BoxDecoration( | |
border: Border.all( | |
width: 10.0, | |
color: Colors.blueGrey, | |
), | |
borderRadius: BorderRadius.all(const Radius.circular(4.0)), | |
), | |
margin: EdgeInsets.all(4.0), | |
child: Image.network( | |
"https://static.lidong.me/upload/XjGwvaVAI.png"), | |
), | |
) | |
], | |
) | |
], | |
), | |
); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Container 容器布局'), | |
), | |
body: container, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment