BeforeValueChanged<T> typedef
if dropdown is changing to a new value , this function is used to check whether new value can be changed or not
isValid
whether current checking is valid or not.
in some cases , if widget is disposed before checking completed
FormeFieldState.didChange
will never be called , some logic in
FormeField.onStatusChanged
or Forme.onFieldStatusChanged
will never
be executed , to prevent these , we need to do our logic in checking
eg:
FormeDropdownButton(
onValueChanged:(f,v) {
logic(f,v);
},
beforeValueChanged:(f,v,isValid) async{
final bool change = await check(f,v);
if(change) {
//checking is valid but field is disposed..
if(isValid() && !f.controller.mounted){
logic(f,v);
}
}
return change
}
)
Future void logic(FormeFieldController field,dynamic value) async{
}
Implementation
typedef BeforeValueChanged<T> = Future<bool> Function(
FormeFieldState<T> field, T value, bool Function() isValid);