mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-15 03:04:25 +08:00
Add:创建 flutter go web 版
This commit is contained in:
@ -1,78 +0,0 @@
|
||||
/// @Author: 一凨
|
||||
/// @Date: 2018-12-22 21:01:51
|
||||
/// @Last Modified by: 一凨
|
||||
/// @Last Modified time: 2018-12-27 15:37:04
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CheckedPopupMenuItemDemo extends StatefulWidget {
|
||||
_CheckedPopupMenuItemDemoState createState() =>
|
||||
_CheckedPopupMenuItemDemoState();
|
||||
}
|
||||
|
||||
class _CheckedPopupMenuItemDemoState extends State<CheckedPopupMenuItemDemo> {
|
||||
List<String> _checkedValues;
|
||||
|
||||
final String _checkedValue1 = 'One';
|
||||
final String _checkedValue2 = 'Two';
|
||||
final String _checkedValue3 = 'Free';
|
||||
final String _checkedValue4 = 'Four';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkedValues = <String>[_checkedValue3];
|
||||
}
|
||||
|
||||
|
||||
bool isChecked(String value) => _checkedValues.contains(value);
|
||||
|
||||
void showCheckedMenuSelections(String value){
|
||||
if(_checkedValues.contains(value)){
|
||||
_checkedValues.remove(value);
|
||||
}else{
|
||||
_checkedValues.add(value);
|
||||
}
|
||||
|
||||
Scaffold.of(context).showSnackBar( SnackBar(
|
||||
content: Text('Checked $_checkedValues')));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Theme.of(context).primaryColor,
|
||||
child: ListTile(
|
||||
title: const Text('CheckedPopupMenuItem Demo',style: TextStyle(color: Colors.white),),
|
||||
trailing: PopupMenuButton<String>(
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: showCheckedMenuSelections,
|
||||
icon: Icon(Icons.menu,color: Colors.white,),
|
||||
itemBuilder: (BuildContext context)=><PopupMenuItem<String>>[
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue1,
|
||||
checked: isChecked(_checkedValue1),
|
||||
child: Text(_checkedValue1)
|
||||
),
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue2,
|
||||
enabled: false,
|
||||
checked: isChecked(_checkedValue2),
|
||||
child: Text(_checkedValue2)
|
||||
),
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue3,
|
||||
checked: isChecked(_checkedValue3),
|
||||
child: Text(_checkedValue3)
|
||||
),
|
||||
CheckedPopupMenuItem<String>(
|
||||
value: _checkedValue4,
|
||||
checked: isChecked(_checkedValue4),
|
||||
child: Text(_checkedValue4)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/// @Author: 一凨
|
||||
/// @Date: 2018-12-22 21:01:45
|
||||
/// @Last Modified by: 一凨
|
||||
/// @Last Modified time: 2018-12-22 21:26:54
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_go/components/widget_demo.dart';
|
||||
import './demo.dart';
|
||||
|
||||
const String content0 = '''
|
||||
### **简介**
|
||||
> 带有选中标记的 Material 设计风格的弹出菜单
|
||||
- 默认高度为48px,水平布局使用 ListTile 复选标记是 Icons.done 图标,显示在 leading 位置
|
||||
- 只有在状态为选中时才会显示图标
|
||||
''';
|
||||
|
||||
const String content1 = '''
|
||||
### **基本用法**
|
||||
> 配合 PopupMenuButton 使用
|
||||
- enabled 属性控制item是否为可点击
|
||||
- checked 标识item是否为选中状态
|
||||
''';
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Menu/CheckedPopupMenuItem';
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
codeUrl: 'components/Menu/CheckedPopupMenuItem/demo.dart',
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/CheckedPopupMenuItem-class.html',
|
||||
title: 'CheckedPopupMenuItem',
|
||||
contentList: [
|
||||
content0,
|
||||
content1,
|
||||
CheckedPopupMenuItemDemo(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user