-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractionally_sized_box.dart
50 lines (47 loc) · 1.37 KB
/
fractionally_sized_box.dart
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
import 'package:flutter/material.dart';
import 'package:flutter_demo/tabbar/mine/component/content_text.dart';
import 'package:flutter_demo/tabbar/mine/component/title_text.dart';
class FractionallySizedBoxPage extends StatefulWidget {
@override
_FractionallySizedBoxPageState createState() => _FractionallySizedBoxPageState();
}
class _FractionallySizedBoxPageState extends State<FractionallySizedBoxPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("FractionallySizedBox"),
),
body: ListView(
children: <Widget>[
TitleTextPage("简介:"),
ContentTextPage(["根据宽高比设置子元素的大小。"]),
TitleTextPage("属性:"),
ContentTextPage([
"widthFactor:宽比。",
"heightFactor:高比。",
"alignment:对齐方式,默认居中。",
]),
TitleTextPage("例子:"),
FractionallySizedBoxDemo()
],
),
);
}
}
class FractionallySizedBoxDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 300,
color: Colors.black12,
child: FractionallySizedBox(
widthFactor: 0.5,
heightFactor: 0.5,
child: Container(
color: Colors.cyan,
),
)
);
}
}