Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 15, 2020 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/dfe293099ca7e967dc9f6cc7022c4954 to your computer and use it in GitHub Desktop.
Save ryanlid/dfe293099ca7e967dc9f6cc7022c4954 to your computer and use it in GitHub Desktop.
Container 容器布局
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