初步优化项目结构

This commit is contained in:
toly
2021-09-26 20:50:13 +08:00
parent f16d031417
commit 29a985e1b1
535 changed files with 366 additions and 359 deletions

View File

@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020/7/20
/// contact me by email 1981462002@qq.com
/// 说明: 328 ChipTheme 主要用于为后代的Chip类型组件统一设置默认属性,也可以通过该组件获取默认Chip的属性。
// {
// "widgetId": 328,
// "name": 'ChipTheme基本使用',
// "priority": 1,
// "subtitle": "可指定ChipThemeData数据属性为【后代】的Chip类型组件设置默认样式属性和Chip属性类似如阴影、颜色、边距、形状、文字样式等。也可以用ChipTheme.of获取Chip的主题数据。",
// }
class ChipThemeDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChipTheme(
data: ChipTheme.of(context).copyWith(
selectedColor: Colors.orange.withAlpha(55),
selectedShadowColor: Colors.blue,
shadowColor: Colors.orangeAccent,
pressElevation: 5,
elevation: 3,
),
child: CustomFilterChip(),
);
}
}
class CustomFilterChip extends StatefulWidget {
@override
_CustomFilterChipState createState() => _CustomFilterChipState();
}
class _CustomFilterChipState extends State<CustomFilterChip> {
final Map<String, String> map = {
'A': 'Ant',
'B': 'Bug',
'C': 'Cat',
'D': 'Dog',
};
List<String> _selected = <String>[];
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Wrap(
children: map.keys.map((key) => _buildChild(key)).toList(),
),
Container(
padding: EdgeInsets.all(10),
child: Text('您已选择: ${_selected.join(', ')}')),
],
);
}
Padding _buildChild(String key) {
return Padding(
padding: const EdgeInsets.all(4.0),
child: FilterChip(
avatar: CircleAvatar(child: Text(key)),
label: Text(map[key]!),
selected: _selected.contains(map[key]),
onSelected: (bool value) {
setState(() {
if (value) {
_selected.add(map[key]!);
} else {
_selected.removeWhere((name) => name == map[key]);
}
});
},
),
);
}
}