Skip to content

Commit d49768a

Browse files
committed
container
1 parent 2a3206e commit d49768a

File tree

1 file changed

+68
-0
lines changed
  • docs/widget/regular/container

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
### Container Demo
2+
3+
``` dart
4+
import 'package:flutter/material.dart';
5+
6+
class Index extends StatelessWidget {
7+
@override
8+
Widget build(BuildContext context) {
9+
return Scaffold(
10+
appBar: AppBar(title: Text('Container Demo'),),
11+
body: ListView(
12+
children: <Widget>[
13+
Center(
14+
child: Container(
15+
child: Text('Hello', style: TextStyle(fontSize: 20.0),),
16+
width: 80.0,
17+
height: 80.0,
18+
margin: const EdgeInsets.all(10.0),
19+
padding: const EdgeInsets.all(10.0),
20+
// color: const Color(0xfff48Fb1),
21+
alignment: Alignment.center,
22+
decoration: BoxDecoration(
23+
color: const Color(0xfff48Fb1),
24+
border: Border.all(width: 2.0, color: Colors.redAccent),
25+
borderRadius: BorderRadius.circular(10.0)
26+
),
27+
),
28+
),
29+
Center(
30+
child: Container(
31+
child: Text(
32+
'Hello World',
33+
style: Theme.of(context).textTheme.display1.copyWith(color: Colors.black),
34+
),
35+
// width: 200.0,
36+
// height: 200.0,
37+
// color: Colors.green,
38+
margin: const EdgeInsets.all(30.0),
39+
padding: const EdgeInsets.all(10.0),
40+
alignment: Alignment.center,
41+
decoration: BoxDecoration(
42+
border: Border.all(width: 2.0, color: Colors.red),
43+
color: Colors.grey,
44+
borderRadius: BorderRadius.all(Radius.circular(20.0)),
45+
image: DecorationImage(
46+
image: NetworkImage('http://sucimg.itc.cn/avatarimg/55d21fdc4b8d4838bef0da94ada78cab_1501139484387'),
47+
centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
48+
// fit: BoxFit.cover
49+
)
50+
),
51+
constraints: BoxConstraints.expand(
52+
height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0
53+
),
54+
foregroundDecoration: BoxDecoration(
55+
image: DecorationImage(
56+
image: NetworkImage('https://www.example.com/images/frame.png'),
57+
centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
58+
)
59+
),
60+
transform: Matrix4.rotationZ(0.1),
61+
),
62+
)
63+
],
64+
)
65+
);
66+
}
67+
}
68+
```

0 commit comments

Comments
 (0)