Skip to content

Commit

Permalink
Merge pull request #51 from laogao/patch-1
Browse files Browse the repository at this point in the history
Provide means to react on validation errors
  • Loading branch information
goxiaoy committed Apr 18, 2023
2 parents c931832 + 4891b0a commit 2f8634f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ui/survey_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SurveyWidget extends StatefulWidget {
final s.Survey survey;
final Map<String, Object?>? answer;
final FutureOr<void> Function(dynamic data)? onSubmit;
final FutureOr<void> Function(dynamic data)? onErrors;
final ValueSetter<Map<String, Object?>?>? onChange;
final bool showQuestionsInOnePage;
final SurveyController? controller;
Expand All @@ -30,6 +31,7 @@ class SurveyWidget extends StatefulWidget {
required this.survey,
this.answer,
this.onSubmit,
this.onErrors,
this.onChange,
this.controller,
this.builder,
Expand Down Expand Up @@ -140,6 +142,7 @@ class SurveyWidgetState extends State<SurveyWidget> {
if (formGroup.valid) {
widget.onSubmit?.call(formGroup.value);
} else {
widget.onErrors?.call(formGroup.errors);
formGroup.markAllAsTouched();
}
}
Expand Down

0 comments on commit 2f8634f

Please sign in to comment.