mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-31 22:18:48 +08:00
add file
This commit is contained in:
@ -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,),
|
||||
),
|
||||
]),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
39
lib/widgets/elements/Frame/Expanded/Expanded/index.dart
Normal file
39
lib/widgets/elements/Frame/Expanded/Expanded/index.dart
Normal 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(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -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(),
|
||||
),
|
||||
];
|
||||
|
Reference in New Issue
Block a user