This commit is contained in:
yifeng.yl
2019-01-08 20:39:13 +08:00
parent 383819e280
commit 2e9702ec7b
242 changed files with 13523 additions and 654 deletions

View File

@ -0,0 +1,73 @@
/*
* @Author: 一凨
* @Date: 2018-11-28 20:09:40
* @Last Modified by: 一凨
* @Last Modified time: 2018-11-28 20:10:32
*/
import 'package:flutter/material.dart';
class ExpandedDemo extends StatelessWidget {
TextStyle txtColor = TextStyle(color: Colors.white);
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Text('Expanded'),
new Row(children: <Widget>[
new RaisedButton(
onPressed: () {
print('点击红色按钮事件');
},
color: const Color(0xffcc0000),
child: new Text('红色按钮',style: txtColor,),
),
new Expanded(
flex: 1,//flex用来设置当前可用空间的占优比
child: new RaisedButton(
onPressed: () {
print('点击黄色按钮事件');
},
color: const Color(0xfff1c232),
child: new Text('黄色按钮',style: txtColor,),
),
),
new RaisedButton(
onPressed: () {
print('点击粉色按钮事件');
},
color: const Color(0xffea9999),
child: new Text('粉色按钮',style: txtColor,),
),
]),
Text('Flexible'),
new Row(children: <Widget>[
new RaisedButton(
onPressed: () {
print('点击红色按钮事件');
},
color: const Color(0xffcc0000),
child: new Text('红色按钮',style: txtColor,),
),
new Flexible(
flex: 1,
child: new RaisedButton(
onPressed: () {
print('点击黄色按钮事件');
},
color: const Color(0xfff1c232),
child: new Text('黄色按钮',style: txtColor,),
),
),
new RaisedButton(
onPressed: () {
print('点击粉色按钮事件');
},
color: const Color(0xffea9999),
child: new Text('粉色按钮',style: txtColor,),
),
]),
],
);
}
}

View File

@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
import '../../../../../common/widget_demo.dart';
import './expanded_demo.dart';
const contentText0 = '''
### **简介**
> 一个用于撑开 flex 布局子组件空间的widget
- 用于在Row、Column、Flex子组件内
- 会沾满所有可用空间
''';
const contentText1 = '''
### **基本用法**
> 以下示例对比使用 ```Expanded```
- 使用Expanded 可以使 Row、Column或者Flex的子项能够填充主轴的全部可用空间
- 如果存在多个子项,则根据 flex 属性来划分可用空间
- Expanded widget 必须是Row,Column或者Flex的后代
''';
class Demo extends StatefulWidget {
static const String routeName = '/element/Frame/Expanded/Expanded';
_DemoState createState() => _DemoState();
}
class _DemoState extends State<Demo> {
@override
Widget build(BuildContext context) {
return WidgetDemo(
title: 'Expanded',
codeUrl: 'elements/Frame/Expanded/Expanded/expanded_demo.dart',
docUrl: 'https://docs.flutter.io/flutter/widgets/Expanded-class.html',
contentList: [
contentText0,
contentText1,
ExpandedDemo(),
],
);
}
}

View File

@ -1 +1,12 @@
import 'package:flutter/material.dart';
import '../../../../model/widget.dart';
import './Expanded/index.dart' as Expanded;
List<WidgetPoint> widgetPoints = [
WidgetPoint(
name: 'Expanded',
routerName: Expanded.Demo.routeName,
buildRouter: (BuildContext context) => Expanded.Demo(),
),
];