I think you want to validate some fields, before opening the expansion tile.
You can use a boolean
variable for that, first set the bool
variable to false
and after that validate
your fields
on the onExpansionChanged
method and show the toast
.
Assign a bool field, When your fields are validated then change that bool
field to true
,
Let the bool
field be false
by default and then use it to hide the expansion tile childrens
if false
, and show the childrens
if set to true
.
bool isValid = false;
ExpansionTile(
onExpansionChanged: (value){
if(isValid){
print(" ok");
}else{
print("Show a toast, Please check all Fields");
}
},
title: Text(
'Title',
),
children: <Widget>[
isValid ? ListTile(
title: Text('data'),
) : new Container(),
],
),
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…