forked from lxm_flutter/FlutterUnit
初步优化项目结构
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/4/27
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
// {
|
||||
// "widgetId": 33,
|
||||
// "priority": 1,
|
||||
// "name": "ToggleButtons单选切换",
|
||||
// "subtitle": "【children】: 子组件集 【List<Widget>】\n"
|
||||
// "【borderWidth】: 边线宽 【double】\n"
|
||||
// "【borderRadius】: 圆角 【BorderRadius】\n"
|
||||
// "【isSelected】: 是否选中集 【List<bool>】\n"
|
||||
// "【onPressed】: 点击事件 【Function(int)】",
|
||||
// }
|
||||
class CustomToggleButtons extends StatefulWidget {
|
||||
@override
|
||||
_CustomToggleButtonsState createState() => _CustomToggleButtonsState();
|
||||
}
|
||||
|
||||
class _CustomToggleButtonsState extends State<CustomToggleButtons> {
|
||||
List<bool> _isSelected = [true, false, false];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ToggleButtons(
|
||||
children: const <Widget>[
|
||||
Icon(Icons.skip_previous),
|
||||
Icon(Icons.pause),
|
||||
Icon(Icons.skip_next),
|
||||
],
|
||||
borderWidth: 1,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
isSelected: _isSelected,
|
||||
onPressed: (value) => setState(() {
|
||||
_isSelected = _isSelected.map((e) => false).toList();
|
||||
_isSelected[value] = true;
|
||||
}),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/4/27
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
// {
|
||||
// "widgetId": 33,
|
||||
// "priority": 2,
|
||||
// "name": "ToggleButtons颜色属性",
|
||||
// "subtitle": "【borderColor】: 边线色 【Color】\n"
|
||||
// "【selectedBorderColor】: 选中边线色 【Color】\n"
|
||||
// "【selectedColor】: 选中时组件色 【Color】\n"
|
||||
// "【fillColor】: 选中时填充色 【Color】\n"
|
||||
// "【splashColor】: 水波纹色 【Color】",
|
||||
// }
|
||||
class ColorToggleButtons extends StatefulWidget {
|
||||
@override
|
||||
_ColorToggleButtonsState createState() => _ColorToggleButtonsState();
|
||||
}
|
||||
|
||||
class _ColorToggleButtonsState extends State<ColorToggleButtons> {
|
||||
List<bool> _isSelected = [true, false, false];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ToggleButtons(
|
||||
children: const <Widget>[
|
||||
Icon(Icons.skip_previous),
|
||||
Icon(Icons.pause),
|
||||
Icon(Icons.skip_next),
|
||||
],
|
||||
borderWidth: 1,
|
||||
borderColor: Colors.orangeAccent,
|
||||
selectedBorderColor: Colors.blue,
|
||||
splashColor: Colors.purple.withAlpha(66),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
selectedColor: Colors.red,
|
||||
fillColor: Colors.green.withAlpha(11),
|
||||
isSelected: _isSelected,
|
||||
onPressed: (value) => setState(() {
|
||||
_isSelected = _isSelected.map((e) => false).toList();
|
||||
_isSelected[value] = true;
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/4/27
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
// {
|
||||
// "widgetId": 33,
|
||||
// "priority": 3,
|
||||
// "name": "ToggleButtons多选切换",
|
||||
// "subtitle": " 可以控制状态转化的逻辑来形成不同的效果。",
|
||||
// }
|
||||
class ProToggleButtons extends StatefulWidget {
|
||||
@override
|
||||
_ProToggleButtonsState createState() => _ProToggleButtonsState();
|
||||
}
|
||||
|
||||
class _ProToggleButtonsState extends State<ProToggleButtons> {
|
||||
List<bool> _isSelected = [false, false, false];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ToggleButtons(
|
||||
children: const <Widget>[
|
||||
Icon(Icons.skip_previous),
|
||||
Icon(Icons.pause),
|
||||
Icon(Icons.skip_next),
|
||||
],
|
||||
borderWidth: 1,
|
||||
borderColor: Colors.blue,
|
||||
selectedBorderColor: Colors.orangeAccent,
|
||||
splashColor: Colors.purple.withAlpha(66),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
selectedColor: Colors.red,
|
||||
fillColor: Colors.green.withAlpha(11),
|
||||
isSelected: _isSelected,
|
||||
onPressed: (value) => setState(() {
|
||||
_isSelected[value] = !_isSelected[value];
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user