Files
ryan730 c0d90db596 Merge branch 'develop' into dev/yisheng
# Conflicts:
#	lib/widgets/components/Bar/AppBar/index.dart
#	lib/widgets/components/Bar/BottomAppBar/demo.dart
#	lib/widgets/components/Bar/BottomAppBar/index.dart
#	lib/widgets/components/Bar/ButtonBar/index.dart
#	lib/widgets/components/Bar/FlexibleSpaceBar/index.dart
#	lib/widgets/components/Bar/SliverAppBar/index.dart
#	lib/widgets/components/Bar/SnackBar/index.dart
#	lib/widgets/components/Bar/SnackBarAction/index.dart
#	lib/widgets/components/Card/Card/index.dart
#	lib/widgets/components/LIst/ListBody/index.dart
#	lib/widgets/components/LIst/ListView/index.dart
#	lib/widgets/elements/Form/Button/DropdownButton/index.dart
#	lib/widgets/elements/Form/Button/FlatButton/index.dart
#	lib/widgets/elements/Form/Button/PopupMenuButton/index.dart
#	lib/widgets/elements/Form/CheckBox/Checkbox/index.dart
#	lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart
#	lib/widgets/elements/Frame/Axis/crossAxis/index.dart
#	lib/widgets/elements/Frame/Axis/flipAxis/index.dart
#	lib/widgets/elements/Frame/Axis/mainAxis/index.dart
#	lib/widgets/elements/Media/Image/precacheImage/index.dart
2019-01-12 17:30:11 +08:00

75 lines
1.7 KiB
Dart

/**
* Created with Android Studio.
* User: 一晟
* Date: 2018/11/22
* Time: 上午12:03
* email: zhu.yan@alibaba-inc.com
* tartget: Checkbox 的示例
*/
import 'dart:math';
import 'package:flutter/material.dart';
/*
* Checkbox 默认的实例
* index 当前checkbox 的索引值
* */
class CheckboxDefault extends StatefulWidget{
final int index;
final parent;
const CheckboxDefault([this.parent, this.index = -1]) : super();
@override
State<StatefulWidget> createState() =>_CheckboxDefault();
}
class _CheckboxDefault extends State {
bool isChecked=false;
Color color = _randomColor(); // 注意和下面的 StatelessWidget 里的 _randomColor 区别
@override
Widget build(BuildContext context) {
return Checkbox(
activeColor: color,
tristate:false,
value: isChecked,
onChanged: (bool bol) {
setState((){
isChecked = bol;
});
}
);
}
}
/*
* Checkbox 默认的实例
* index 当前checkbox 的索引值
* */
class CheckboxSelect extends StatelessWidget {
final int index;
final widget;
final parent;
const CheckboxSelect([this.widget,this.parent, this.index = -1])
: super();
@override
Widget build(BuildContext context) {
Color color = _randomColor();
return Checkbox(
activeColor: color,
tristate:false,
value: parent.selectValue == this.index,
onChanged: (bool bol) {
parent.setState((){
parent.selectValue = bol ? this.index : -1;
});
}
);
}
}
Color _randomColor() {
var red = Random.secure().nextInt(255);
var greed = Random.secure().nextInt(255);
var blue = Random.secure().nextInt(255);
return Color.fromARGB(255, red, greed, blue);
}