mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-31 22:18:48 +08:00
fix: 部分代码添加 mounted
This commit is contained in:
@ -124,9 +124,11 @@ class DropdownButtonCustom extends StatelessWidget {
|
||||
value: selectItemValue,
|
||||
//下拉菜单item点击之后的回调
|
||||
onChanged: (T){
|
||||
parent.setState((){
|
||||
selectItemValue = T;
|
||||
});
|
||||
if (parent.mounted) {
|
||||
parent.setState(() {
|
||||
selectItemValue = T;
|
||||
});
|
||||
}
|
||||
},
|
||||
//设置阴影的高度
|
||||
elevation: 24,
|
||||
|
@ -50,9 +50,11 @@ class _DemoState extends State<Demo> {
|
||||
String buttonShapeType = 'border'; // 边框类型
|
||||
void setButtonShapeType(){
|
||||
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
|
||||
this.setState((){
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
if(mounted) {
|
||||
this.setState(() {
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -45,9 +45,11 @@ class _DemoState extends State<Demo> {
|
||||
String buttonShapeType = 'border'; // 边框类型
|
||||
void setButtonShapeType(){
|
||||
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
|
||||
this.setState((){
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
if(mounted) {
|
||||
this.setState(() {
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -54,9 +54,11 @@ class _DemoState extends State<Demo> {
|
||||
String buttonShapeType = 'border'; // 边框类型
|
||||
void setButtonShapeType(){
|
||||
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
|
||||
this.setState((){
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
if (mounted) {
|
||||
this.setState(() {
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -53,9 +53,11 @@ class _DemoState extends State<Demo> {
|
||||
String buttonShapeType = 'border'; // 边框类型
|
||||
void setButtonShapeType(){
|
||||
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
|
||||
this.setState((){
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
if(mounted) {
|
||||
this.setState(() {
|
||||
buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -43,9 +43,11 @@ class _DemoState extends State<Demo> {
|
||||
String buttonShapeType = 'border'; // 边框类型
|
||||
void setButtonShapeType(){
|
||||
//String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
|
||||
this.setState((){
|
||||
//buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
if( mounted ) {
|
||||
this.setState(() {
|
||||
//buttonShapeType = _buttonShapeType;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -30,9 +30,11 @@ class _CheckboxDefault extends State {
|
||||
tristate:false,
|
||||
value: isChecked,
|
||||
onChanged: (bool bol) {
|
||||
setState((){
|
||||
isChecked = bol;
|
||||
});
|
||||
if(mounted) {
|
||||
setState(() {
|
||||
isChecked = bol;
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -58,9 +60,11 @@ class CheckboxSelect extends StatelessWidget {
|
||||
tristate:false,
|
||||
value: parent.selectValue == this.index,
|
||||
onChanged: (bool bol) {
|
||||
parent.setState((){
|
||||
parent.selectValue = bol ? this.index : -1;
|
||||
});
|
||||
if(parent.mounted) {
|
||||
parent.setState(() {
|
||||
parent.selectValue = bol ? this.index : -1;
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ class _CheckboxListTileStateDefault extends State {
|
||||
for (var i = 0; i < isChecks.length; i++) {
|
||||
isChecks[i] = value;
|
||||
}
|
||||
setState(() => _value = value);
|
||||
if(mounted) {
|
||||
setState(() => _value = value);
|
||||
}
|
||||
}
|
||||
bool isCheck=false;
|
||||
List<bool> isChecks=[false,false,false,false];
|
||||
@ -55,9 +57,11 @@ class _CheckboxListTileStateDefault extends State {
|
||||
activeColor: _value ? Colors.red : Colors.green,
|
||||
controlAffinity: ListTileControlAffinity.platform,
|
||||
onChanged: (bool){
|
||||
setState(() {
|
||||
isChecks[0]=bool;
|
||||
});
|
||||
if(mounted) {
|
||||
setState(() {
|
||||
isChecks[0] = bool;
|
||||
});
|
||||
}
|
||||
}),
|
||||
),
|
||||
Center(
|
||||
|
Reference in New Issue
Block a user