Flutter Widget之Container

Widget:https://flutter.io/docs/development/ui/widgets
Container:https://docs.flutter.io/flutter/widgets/Container-class.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import 'package:flutter/material.dart';

class ContainerDemoPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _ContainerDemoPageState();
}

class _ContainerDemoPageState extends State<ContainerDemoPage> {
@override
Widget build(BuildContext context) {
Expanded imageExpanded(String img) {
return new Expanded(child: new Container(
decoration: new BoxDecoration(
border: new Border.all(width: 10.0, color: Colors.black38),
borderRadius: const BorderRadius.all(
const Radius.circular(8.0))),
margin: const EdgeInsets.all(4.0),
child: new Image.asset(img),
));
}

var container = new Container(
decoration: new BoxDecoration(color: Colors.black26),
child: new Column(
children: <Widget>[
new Row(children: <Widget>[
imageExpanded('images/lion.jpg'),
imageExpanded('images/parrot.jpg'),
],),
new Row(children: <Widget>[
imageExpanded('images/dog.jpg'),
imageExpanded('images/cat.jpg'),
],),
new Row(children: <Widget>[
imageExpanded('images/husky.jpg'),
],)
],
),
);

return new Scaffold(
appBar: new AppBar(title: new Text('Container Page Demo'),),
// body: new SingleChildScrollView(
// child: new Center(
// child: container,
// ),
// )

body: Center(
// child: Container(
// margin: const EdgeInsets.all(10.0),
// color: const Color(0xFF00FF00),
// width: 48.0,
// height: 48.0,
// ),
child: Container(
constraints: BoxConstraints.expand(
height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0,
),
padding: const EdgeInsets.all(8.0),
color: Colors.teal.shade700,
alignment: Alignment.center,
child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)),
foregroundDecoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('http://www.appblog.com/css/images/logo128.jpg'),
centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
),
),
transform: Matrix4.rotationZ(0.1),
)
),
);
}
}

Flutter Widget Container

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :