mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-31 14:08:55 +08:00
add file
This commit is contained in:
77
lib/widgets/components/Chip/inputChip/demo.dart
Normal file
77
lib/widgets/components/Chip/inputChip/demo.dart
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* @Author: xiaojia.dxj
|
||||
* @Date: 2018-12-20 13:32:22
|
||||
* @Last Modified by: xiaojia.dxj
|
||||
* @Last Modified time: 2018-12-21 11:31:12
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FilterChipDemo extends StatefulWidget {
|
||||
_FilterChipDemoState createState() => _FilterChipDemoState();
|
||||
}
|
||||
|
||||
class InputEntry{
|
||||
final String name;
|
||||
final String initials;
|
||||
const InputEntry(this.name,this.initials);
|
||||
|
||||
}
|
||||
|
||||
class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
|
||||
final List<InputEntry> _lists=<InputEntry>[
|
||||
const InputEntry('android', 'A'),
|
||||
const InputEntry('java', 'J'),
|
||||
const InputEntry('php', 'P'),
|
||||
const InputEntry('web', 'W'),
|
||||
];
|
||||
|
||||
List<InputEntry> _inputLists=<InputEntry>[];
|
||||
Iterable<Widget> get inputWidget sync*{
|
||||
for(InputEntry value in _lists){
|
||||
_inputLists.add(value);
|
||||
yield Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: InputChip(
|
||||
avatar: CircleAvatar(
|
||||
backgroundColor: Colors.redAccent.shade400,
|
||||
child: Text(value.initials),
|
||||
),
|
||||
label: Text(value.name),
|
||||
onDeleted: (){
|
||||
setState(() {
|
||||
_lists.remove(value);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Wrap(
|
||||
children: inputWidget.toList(),
|
||||
),
|
||||
// InputChip(
|
||||
// label: Text('刷新'),
|
||||
// onSelected: (bool value){
|
||||
|
||||
// },
|
||||
// )
|
||||
],
|
||||
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
43
lib/widgets/components/Chip/inputChip/index.dart
Normal file
43
lib/widgets/components/Chip/inputChip/index.dart
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @Author: xiaojia.dxj
|
||||
* @Date: 2018-12-20 13:32:15
|
||||
* @Last Modified by: xiaojia.dxj
|
||||
* @Last Modified time: 2018-12-21 10:42:05
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../common/widget_demo.dart';
|
||||
import 'demo.dart';
|
||||
|
||||
const String content0 = '''
|
||||
### **简介**
|
||||
> 输入型chip
|
||||
- 以紧凑的形式表现复杂的信息,例如:实体(人,地点,或者事物)或者会话文本
|
||||
|
||||
''';
|
||||
const String content1 = '''
|
||||
### **基本用法**
|
||||
- inputChip可以通过设置进行选择onSelected,通过设置onDeleted可以删除,并且可以通过OnPressed表现按压效果
|
||||
- inputChip 有一个前导图标和尾随图标,填充颜色可以订制
|
||||
- inputChip 可以和其他UI元素搭配使用,比如:wrap,ListView(scrollDirection为Axis.horizontal)
|
||||
''';
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Chip/InputChip';
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
contentList: [
|
||||
content0,
|
||||
content1,
|
||||
FilterChipDemo(),
|
||||
],
|
||||
codeUrl: 'components/Chip/FilterChip/demo.dart',
|
||||
docUrl:'https://docs.flutter.io/flutter/material/InputChip-class.html',
|
||||
title: 'InputChip');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user