mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-06-01 23:43:54 +08:00
modify some description
This commit is contained in:
@ -8,12 +8,17 @@ import 'package:flutter/widgets.dart';
|
||||
* LastUpdateTime: 2018/11/22
|
||||
* LastUpdateBy: xj.deng
|
||||
*
|
||||
* Describle:Align描述
|
||||
* Describle:ConstrainedBox描述
|
||||
*/
|
||||
class ConstracubedBox extends StatelessWidget {
|
||||
class ConstrainedBoxCreate extends StatelessWidget {
|
||||
final double currWidth;
|
||||
final String describe;
|
||||
|
||||
const ConstrainedBoxCreate({Key key,this.currWidth,this.describe}):
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
ConstrainedBox(
|
||||
@ -21,20 +26,22 @@ class ConstracubedBox extends StatelessWidget {
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 100.0,
|
||||
minHeight: 20.0,
|
||||
maxWidth: 500.0,
|
||||
maxWidth: 300.0,
|
||||
maxHeight: 50.0,
|
||||
),
|
||||
child: new Container(
|
||||
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
|
||||
//child 宽高超过制定限制范围失效,效果宽/高=100/20区域
|
||||
width: 600.0,
|
||||
width: currWidth,
|
||||
height: 250.0,
|
||||
child: new Text('ConstrainedBox',style: TextStyle(color: Colors.white),),
|
||||
color: Colors.red,
|
||||
child: new Text(
|
||||
describe,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
color: Color(0xfff8bbd0),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,11 @@ const String _Text = '''
|
||||
const String _Text1 = '''
|
||||
### **基本用法**
|
||||
> 添加额外的限制条件到child上
|
||||
- 比如说,你限制child最小高度为50.0像素,就可以用constraints: const BoxConstraints(minHeight:50)
|
||||
- ex:添加ConstrainedBox约束如下,传入不同Width约束的Container效果
|
||||
minWidth: 100.0,
|
||||
minHeight: 20.0,
|
||||
maxWidth: 300.0,
|
||||
maxHeight: 50.0
|
||||
|
||||
''';
|
||||
|
||||
@ -36,7 +40,27 @@ class _DemoState extends State<Demo> {
|
||||
contentList: [
|
||||
_Text,
|
||||
_Text1,
|
||||
ConstracubedBox(),
|
||||
// maxWidth: 300.0,
|
||||
ConstrainedBoxCreate(currWidth: 500, describe: "currWidth>maxWidth"),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
ConstrainedBoxCreate(currWidth: 300, describe: "currWidth=maxWidth"),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
ConstrainedBoxCreate(currWidth: 200, describe: "currWidth<maxWidth"),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
|
||||
// minWidth: 100.0,
|
||||
ConstrainedBoxCreate(currWidth: 150, describe: "currWidth>minWidth"),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
ConstrainedBoxCreate(currWidth: 100, describe: "currWidth=minWidth"),
|
||||
|
||||
],
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/widgets/ConstrainedBox-class.html',
|
||||
|
Reference in New Issue
Block a user