Skip to content

Commit

Permalink
Merge pull request #108 from wwt/Issue107
Browse files Browse the repository at this point in the history
Made it so that SurveyWidgetState.submit returns bool instead of void
  • Loading branch information
goxiaoy committed Jul 27, 2023
2 parents 2817ea6 + b56959c commit 1349a2f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/ui/survey_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ class SurveyWidgetState extends State<SurveyWidget> {
}
}

void submit() {
bool submit() {
if (formGroup.valid) {
widget.onSubmit?.call(formGroup.value);
return true;
} else {
widget.onErrors?.call(formGroup.errors);
formGroup.markAllAsTouched();
return false;
}
}

Expand Down Expand Up @@ -235,9 +237,9 @@ class SurveyController {
_widgetState = null;
}

void submit() {
bool submit() {
assert(_widgetState != null, "SurveyWidget not initialized");
_widgetState?.submit();
return _widgetState!.submit();
}

// nextPageOrSubmit return true if submit or return false for next page
Expand Down

0 comments on commit 1349a2f

Please sign in to comment.