mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 19:03:47 +02:00
fix: onchange of switch not firing
This commit is contained in:
parent
39a09251c6
commit
275e0d51b8
3 changed files with 11 additions and 0 deletions
|
@ -30,3 +30,7 @@
|
||||||
- Added the id of the input field on the input check widget.
|
- Added the id of the input field on the input check widget.
|
||||||
- Ability to set the height of the carousel input field.
|
- Ability to set the height of the carousel input field.
|
||||||
- InputController now contains the onSubmit callback.
|
- InputController now contains the onSubmit callback.
|
||||||
|
|
||||||
|
## 2.0.1 - October 27th 2022
|
||||||
|
|
||||||
|
- onChange of switch input not firing fixed
|
||||||
|
|
|
@ -25,6 +25,7 @@ class FlutterFormInputSwitch extends FlutterFormInputWidget<bool> {
|
||||||
onSaved: (value) {
|
onSaved: (value) {
|
||||||
controller.onSaved(value);
|
controller.onSaved(value);
|
||||||
},
|
},
|
||||||
|
onChanged: controller.onChanged,
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
initialValue: controller.value ?? false,
|
initialValue: controller.value ?? false,
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,6 +7,7 @@ class SwitchFormField extends FormField<bool> {
|
||||||
required FormFieldValidator<bool> validator,
|
required FormFieldValidator<bool> validator,
|
||||||
bool initialValue = false,
|
bool initialValue = false,
|
||||||
bool autovalidate = false,
|
bool autovalidate = false,
|
||||||
|
void Function(bool? value)? onChanged,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
onSaved: onSaved,
|
onSaved: onSaved,
|
||||||
|
@ -16,6 +17,7 @@ class SwitchFormField extends FormField<bool> {
|
||||||
return SwitchWidget(
|
return SwitchWidget(
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
state: state,
|
state: state,
|
||||||
|
onChanged: onChanged,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -24,11 +26,13 @@ class SwitchWidget extends StatefulWidget {
|
||||||
const SwitchWidget({
|
const SwitchWidget({
|
||||||
this.initialValue = false,
|
this.initialValue = false,
|
||||||
required this.state,
|
required this.state,
|
||||||
|
this.onChanged,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool initialValue;
|
final bool initialValue;
|
||||||
final FormFieldState<bool> state;
|
final FormFieldState<bool> state;
|
||||||
|
final void Function(bool? value)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SwitchWidget> createState() => _SwitchWidgetState();
|
State<SwitchWidget> createState() => _SwitchWidgetState();
|
||||||
|
@ -42,6 +46,8 @@ class _SwitchWidgetState extends State<SwitchWidget> {
|
||||||
return Switch(
|
return Switch(
|
||||||
value: value,
|
value: value,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool value) {
|
||||||
|
widget.onChanged?.call(value);
|
||||||
|
|
||||||
widget.state.didChange(value);
|
widget.state.didChange(value);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
Loading…
Reference in a new issue