Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Test #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ckken merged 13 commits into master from test
Mar 1, 2019
Merged

Test #13

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ConstrainedBox
  • Loading branch information
DIVINER-only committed Feb 28, 2019
commit 091fad851c66ae8f02a3355aa7fcdb3320cf57c3
20 changes: 20 additions & 0 deletions docs/widget/regular/constrainedbox/index.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## **ConstrainedBox**

>
一个基础布局控件,添加额外的限制条件(constraints)到child上

### 构造方法
``` dart
ConstrainedBox({
Key key,
@required this.constraints,
Widget child
})
```

### 属性介绍
* constraints: 添加到child上的额外限制条件,其类型为BoxConstraints,限制各种最大最小宽高
* child: ConstrainedBox中的内容Widget

### 其他用法
* constraints值为BoxConstraints.expand时,提供width或者height,那么限制(Constraints)将严格使用给出的width或者height值
63 changes: 63 additions & 0 deletions lib/widget/regular/constrainedbox/demo.dart
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';

class Index extends StatefulWidget {
@override
_IndexState createState() => _IndexState();
}

class _IndexState extends State<Index> {
var maxWidth = 200.0;
var maxHeight = 200.0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('ConstrainedBox'),),
body: ListView(
children: <Widget>[
SizedBox(
child: Text('修改maxWidth maxHeight 值'),
),
Row(
children: <Widget>[
FlatButton(
child: Text('maxWidth: $maxWidth', style: TextStyle(fontSize: 14.0),),
onPressed: (){
setState(() {
maxWidth == 200.0 ? maxWidth = 150.0 : maxWidth = 200.0;
});
},
),
FlatButton(
child: Text('maxHeight: $maxHeight', style: TextStyle(fontSize: 14.0),),
onPressed: (){
setState(() {
maxHeight == 200.0 ? maxHeight = 150.0 : maxHeight = 200.0;
});
},
)
],
),
Center(
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: 100.0,
minHeight: 100.0,
maxWidth: maxWidth,
maxHeight: maxHeight
),
child: Container(
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('http://sucimg.itc.cn/avatarimg/55d21fdc4b8d4838bef0da94ada78cab_1501139484387')
),
color: Theme.of(context).primaryColor,
),
),
),
),
],
),
);
}
}
26 changes: 26 additions & 0 deletions lib/widget/regular/constrainedbox/demo_expand.dart
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';

class Index extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Expand'),),
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints.expand(
width: 150.0,
height: 150.0
),
child: Container(
alignment: Alignment.center,
color: Theme.of(context).primaryColor,
child: Text(
'Hello World',
style: TextStyle(fontSize: 20.0, color: Colors.white, fontWeight: FontWeight.bold)
),
),
),
),
);
}
}
27 changes: 27 additions & 0 deletions lib/widget/regular/constrainedbox/index.dart
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
import 'demo.dart' as Demo;
import 'demo_expand.dart' as DemoExpand;

class Index extends StatefulWidget {
static String title = 'ConstrainedBox';
static String originCodeUrl = '';
static String mdUrl = 'docs/widget/regular/constrainedbox/index.md';
@override
_IndexState createState() => _IndexState();
}

class _IndexState extends State<Index> {
@override
Widget build(BuildContext context) {
return WidgetComp.Index(
title: Index.title,
originCodeUrl: Index.originCodeUrl,
mdUrl: Index.mdUrl,
demoChild: <Widget>[
Demo.Index(),
DemoExpand.Index()
],
);
}
}
6 changes: 6 additions & 0 deletions lib/widget/regular/index.dart
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'align/index.dart' as Align;
import 'center/index.dart' as Center;
import 'fittedbox/index.dart' as FittedBox;
import 'aspectratio/index.dart' as AspectRatio;
import 'constrainedbox/index.dart' as ConstrainedBox;

const nameSpaces = '/regular_';

Expand Down Expand Up @@ -50,6 +51,11 @@ List widgets = [
widget: AspectRatio.Index(),
code: 58688, // local_bar
title: AspectRatio.Index.title
),
ItemInfo(
widget: ConstrainedBox.Index(),
code: 57709, // low_priority
title: ConstrainedBox.Index.title
)
];

Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ flutter:
- docs/widget/regular/center/
- docs/widget/regular/fittedbox/
- docs/widget/regular/aspectratio/
- docs/widget/regular/constrainedbox/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.

Expand Down

AltStyle によって変換されたページ (->オリジナル) /