submit method

dynamic submit({
  1. required dynamic onSuccess(
    1. dynamic value
    ),
  2. dynamic onFailure(
    1. Exception exception
    )?,
  3. bool showToastError = true,
})

Submit the form If the form is valid, it will call the onSuccess function

Implementation

submit(
    {required Function(dynamic value) onSuccess,
    Function(Exception exception)? onFailure,
    bool showToastError = true}) {
  Map<String, dynamic> rules = getValidate;
  if (rules.isEmpty) {
    onSuccess(data());
    return;
  }

  /// Update the state with the rules and the onSuccess function
  updateState(stateName, data: {
    "onSuccess": onSuccess,
    "onFailure": onFailure,
    "showToastError": showToastError
  });
}