mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 19:03:47 +02:00
Added onChange to formInputControllers
This commit is contained in:
parent
9c76d2766a
commit
1eeaf65359
13 changed files with 86 additions and 72 deletions
|
@ -23,6 +23,7 @@ class _FormExampleState extends ConsumerState<FormExample> {
|
||||||
checkPageTitle: (dynamic amount) {
|
checkPageTitle: (dynamic amount) {
|
||||||
return "Age: $amount years";
|
return "Age: $amount years";
|
||||||
},
|
},
|
||||||
|
onChanged: (value) => print(value),
|
||||||
);
|
);
|
||||||
|
|
||||||
late final FlutterFormInputCarouselController carouselInputController;
|
late final FlutterFormInputCarouselController carouselInputController;
|
||||||
|
@ -49,6 +50,7 @@ class _FormExampleState extends ConsumerState<FormExample> {
|
||||||
checkPageTitle: (dynamic firstName) {
|
checkPageTitle: (dynamic firstName) {
|
||||||
return "First Name: $firstName";
|
return "First Name: $firstName";
|
||||||
},
|
},
|
||||||
|
onChanged: (value) => print(value),
|
||||||
);
|
);
|
||||||
|
|
||||||
FlutterFormInputPlainTextController lastNameController =
|
FlutterFormInputPlainTextController lastNameController =
|
||||||
|
@ -58,6 +60,7 @@ class _FormExampleState extends ConsumerState<FormExample> {
|
||||||
checkPageTitle: (dynamic lastName) {
|
checkPageTitle: (dynamic lastName) {
|
||||||
return "Last Name: $lastName";
|
return "Last Name: $lastName";
|
||||||
},
|
},
|
||||||
|
onChanged: (value) => print(value),
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -71,6 +74,7 @@ class _FormExampleState extends ConsumerState<FormExample> {
|
||||||
checkPageDescription: (dynamic index) {
|
checkPageDescription: (dynamic index) {
|
||||||
return cars[index]["description"];
|
return cars[index]["description"];
|
||||||
},
|
},
|
||||||
|
onChanged: (value) => print(value),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.16.0"
|
||||||
crypto:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: crypto
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.2"
|
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -154,13 +147,6 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.99"
|
version: "0.0.99"
|
||||||
sliding_up_panel:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: sliding_up_panel
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0+1"
|
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -210,20 +196,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.12"
|
version: "0.4.12"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
uuid:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: uuid
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.6"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import '/src/utils/formstate.dart' as fs;
|
||||||
/// label is a standard parameter to normally sets the label of the input.
|
/// label is a standard parameter to normally sets the label of the input.
|
||||||
///
|
///
|
||||||
/// [registerController] should be called to register the given [controller] to the form page.
|
/// [registerController] should be called to register the given [controller] to the form page.
|
||||||
abstract class FlutterFormInputWidget extends ConsumerWidget {
|
abstract class FlutterFormInputWidget<T> extends ConsumerWidget {
|
||||||
const FlutterFormInputWidget({
|
const FlutterFormInputWidget({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
|
@ -19,7 +19,7 @@ abstract class FlutterFormInputWidget extends ConsumerWidget {
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The [controller] which determines how the value is handled and how the value is shown on the checkpage.
|
/// The [controller] which determines how the value is handled and how the value is shown on the checkpage.
|
||||||
final FlutterFormInputController controller;
|
final FlutterFormInputController<T> controller;
|
||||||
|
|
||||||
/// [label] is a standard parameter to normally sets the label of the input.
|
/// [label] is a standard parameter to normally sets the label of the input.
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
@ -56,6 +56,8 @@ abstract class FlutterFormInputWidget extends ConsumerWidget {
|
||||||
/// [checkPageDescription] is the same as checkPageTitle but for the description.
|
/// [checkPageDescription] is the same as checkPageTitle but for the description.
|
||||||
/// If null no description will be shown.
|
/// If null no description will be shown.
|
||||||
///
|
///
|
||||||
|
/// [onChanged] can be set to get the value whenever the user changes it.
|
||||||
|
///
|
||||||
/// [onSaved] goes of when the save function is called for the page if [onValidate] return null.
|
/// [onSaved] goes of when the save function is called for the page if [onValidate] return null.
|
||||||
///
|
///
|
||||||
/// [onValidate] is used to validate the given input by the user.
|
/// [onValidate] is used to validate the given input by the user.
|
||||||
|
@ -78,16 +80,19 @@ abstract class FlutterFormInputController<T> {
|
||||||
/// return "$amount persons";
|
/// return "$amount persons";
|
||||||
/// },
|
/// },
|
||||||
/// ```
|
/// ```
|
||||||
String Function(T value)? checkPageTitle;
|
String Function(T? value)? checkPageTitle;
|
||||||
|
|
||||||
/// [checkPageDescription] is the same as checkPageTitle but for the description.
|
/// [checkPageDescription] is the same as checkPageTitle but for the description.
|
||||||
/// If null no description will be shown.
|
/// If null no description will be shown.
|
||||||
String Function(T value)? checkPageDescription;
|
String Function(T? value)? checkPageDescription;
|
||||||
|
|
||||||
|
/// [onChanged] can be set to get the value whenever the user changes it.
|
||||||
|
void Function(T? value)? onChanged;
|
||||||
|
|
||||||
/// [onSaved] goes of when the save function is called for the page if [onValidate] return null.
|
/// [onSaved] goes of when the save function is called for the page if [onValidate] return null.
|
||||||
void onSaved(T value);
|
void onSaved(T? value);
|
||||||
|
|
||||||
/// [onValidate] is used to validate the given input by the user.
|
/// [onValidate] is used to validate the given input by the user.
|
||||||
String? onValidate(
|
String? onValidate(
|
||||||
T value, String Function(String, {List<String>? params}) translator);
|
T? value, String Function(String, {List<String>? params}) translator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ class CarouselFormField extends FormField<int> {
|
||||||
Key? key,
|
Key? key,
|
||||||
required FormFieldSetter<int> onSaved,
|
required FormFieldSetter<int> onSaved,
|
||||||
required FormFieldValidator<int> validator,
|
required FormFieldValidator<int> validator,
|
||||||
|
void Function(int value)? onChanged,
|
||||||
int initialValue = 0,
|
int initialValue = 0,
|
||||||
bool autovalidate = false,
|
bool autovalidate = false,
|
||||||
required List<Widget> items,
|
required List<Widget> items,
|
||||||
|
@ -19,6 +20,8 @@ class CarouselFormField extends FormField<int> {
|
||||||
options: CarouselOptions(
|
options: CarouselOptions(
|
||||||
initialPage: initialValue,
|
initialPage: initialValue,
|
||||||
onPageChanged: (index, reason) {
|
onPageChanged: (index, reason) {
|
||||||
|
onChanged?.call(index);
|
||||||
|
|
||||||
state.didChange(index);
|
state.didChange(index);
|
||||||
},
|
},
|
||||||
height: 425,
|
height: 425,
|
||||||
|
|
|
@ -10,10 +10,10 @@ import 'carousel_form.dart';
|
||||||
/// [items] will be the [Widget]s to be displayed in the carousel.
|
/// [items] will be the [Widget]s to be displayed in the carousel.
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputCarouselController].
|
/// Standard controller is [FlutterFormInputCarouselController].
|
||||||
class FlutterFormInputCarousel extends FlutterFormInputWidget {
|
class FlutterFormInputCarousel extends FlutterFormInputWidget<int> {
|
||||||
const FlutterFormInputCarousel({
|
const FlutterFormInputCarousel({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<int> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
required this.items,
|
required this.items,
|
||||||
}) : super(key: key, controller: controller, label: label);
|
}) : super(key: key, controller: controller, label: label);
|
||||||
|
@ -30,6 +30,7 @@ class FlutterFormInputCarousel extends FlutterFormInputWidget {
|
||||||
return CarouselFormField(
|
return CarouselFormField(
|
||||||
onSaved: (value) => controller.onSaved(value),
|
onSaved: (value) => controller.onSaved(value),
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
|
onChanged: controller.onChanged,
|
||||||
initialValue: controller.value ?? 0,
|
initialValue: controller.value ?? 0,
|
||||||
items: items,
|
items: items,
|
||||||
);
|
);
|
||||||
|
@ -47,6 +48,7 @@ class FlutterFormInputCarouselController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -59,19 +61,22 @@ class FlutterFormInputCarouselController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(int value)? checkPageTitle;
|
String Function(int? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(int value)? checkPageDescription;
|
String Function(int? value)? checkPageDescription;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(int value) {
|
void Function(int? value)? onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onSaved(int? value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? onValidate(
|
String? onValidate(
|
||||||
int value, String Function(String, {List<String>? params}) translator) {
|
int? value, String Function(String, {List<String>? params}) translator) {
|
||||||
if (mandatory) {}
|
if (mandatory) {}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -7,10 +7,10 @@ import '../../../../flutter_form.dart';
|
||||||
/// Input for an email used in a [FlutterForm].
|
/// Input for an email used in a [FlutterForm].
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputEmailController].
|
/// Standard controller is [FlutterFormInputEmailController].
|
||||||
class FlutterFormInputEmail extends FlutterFormInputWidget {
|
class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
||||||
const FlutterFormInputEmail({
|
const FlutterFormInputEmail({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<String> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -31,6 +31,7 @@ class FlutterFormInputEmail extends FlutterFormInputWidget {
|
||||||
controller.onSaved(value);
|
controller.onSaved(value);
|
||||||
},
|
},
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
|
onChanged: (value) => controller.onChanged?.call(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
focusColor: Theme.of(context).primaryColor,
|
focusColor: Theme.of(context).primaryColor,
|
||||||
label: label ?? const Text("Email"),
|
label: label ?? const Text("Email"),
|
||||||
|
@ -50,6 +51,7 @@ class FlutterFormInputEmailController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -62,10 +64,13 @@ class FlutterFormInputEmailController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageTitle;
|
String Function(String? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageDescription;
|
String Function(String? value)? checkPageDescription;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void Function(String? value)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(dynamic value) {
|
void onSaved(dynamic value) {
|
||||||
|
|
|
@ -11,10 +11,10 @@ import 'numberpicker.dart';
|
||||||
/// [maxValue] sets the maximal value of the picker.
|
/// [maxValue] sets the maximal value of the picker.
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputNumberPickerController].
|
/// Standard controller is [FlutterFormInputNumberPickerController].
|
||||||
class FlutterFormInputNumberPicker extends FlutterFormInputWidget {
|
class FlutterFormInputNumberPicker extends FlutterFormInputWidget<int> {
|
||||||
const FlutterFormInputNumberPicker({
|
const FlutterFormInputNumberPicker({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<int> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
this.minValue = 0,
|
this.minValue = 0,
|
||||||
this.maxValue = 100,
|
this.maxValue = 100,
|
||||||
|
@ -34,10 +34,9 @@ class FlutterFormInputNumberPicker extends FlutterFormInputWidget {
|
||||||
return NumberPickerFormField(
|
return NumberPickerFormField(
|
||||||
minValue: minValue,
|
minValue: minValue,
|
||||||
maxValue: maxValue,
|
maxValue: maxValue,
|
||||||
onSaved: (value) {
|
onSaved: (value) => controller.onSaved(value),
|
||||||
controller.onSaved(value);
|
|
||||||
},
|
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
|
onChanged: (value) => controller.onChanged?.call(value),
|
||||||
initialValue: controller.value ?? minValue,
|
initialValue: controller.value ?? minValue,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +50,7 @@ class NumberPickerFormField extends FormField<int> {
|
||||||
Key? key,
|
Key? key,
|
||||||
required FormFieldSetter<int> onSaved,
|
required FormFieldSetter<int> onSaved,
|
||||||
required FormFieldValidator<int> validator,
|
required FormFieldValidator<int> validator,
|
||||||
|
void Function(int value)? onChanged,
|
||||||
int initialValue = 0,
|
int initialValue = 0,
|
||||||
bool autovalidate = false,
|
bool autovalidate = false,
|
||||||
int minValue = 0,
|
int minValue = 0,
|
||||||
|
@ -66,6 +66,8 @@ class NumberPickerFormField extends FormField<int> {
|
||||||
maxValue: maxValue,
|
maxValue: maxValue,
|
||||||
value: initialValue,
|
value: initialValue,
|
||||||
onChanged: (int value) {
|
onChanged: (int value) {
|
||||||
|
onChanged?.call(value);
|
||||||
|
|
||||||
state.didChange(value);
|
state.didChange(value);
|
||||||
},
|
},
|
||||||
itemHeight: 35,
|
itemHeight: 35,
|
||||||
|
@ -82,6 +84,7 @@ class FlutterFormInputNumberPickerController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -94,19 +97,22 @@ class FlutterFormInputNumberPickerController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(int value)? checkPageTitle;
|
String Function(int? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(int value)? checkPageDescription;
|
String Function(int? value)? checkPageDescription;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(int value) {
|
void Function(int? value)? onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onSaved(int? value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? onValidate(
|
String? onValidate(
|
||||||
int value, String Function(String, {List<String>? params}) translator) {
|
int? value, String Function(String, {List<String>? params}) translator) {
|
||||||
if (mandatory) {}
|
if (mandatory) {}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,10 +6,10 @@ import '../../../../../flutter_form.dart';
|
||||||
/// Input for a password used in a [FlutterForm].
|
/// Input for a password used in a [FlutterForm].
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputEmailController].
|
/// Standard controller is [FlutterFormInputEmailController].
|
||||||
class FlutterFormInputPassword extends FlutterFormInputWidget {
|
class FlutterFormInputPassword extends FlutterFormInputWidget<String> {
|
||||||
const FlutterFormInputPassword({
|
const FlutterFormInputPassword({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<String> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
}) : super(key: key, controller: controller, label: label);
|
}) : super(key: key, controller: controller, label: label);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class FlutterFormInputPasswordController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -47,10 +48,13 @@ class FlutterFormInputPasswordController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageTitle;
|
String Function(String? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageDescription;
|
String Function(String? value)? checkPageDescription;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void Function(String? value)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(dynamic value) {
|
void onSaved(dynamic value) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ class _PasswordTextFieldState extends ConsumerState<PasswordTextField> {
|
||||||
obscureText: obscured,
|
obscureText: obscured,
|
||||||
onSaved: (value) => widget.controller.onSaved(value),
|
onSaved: (value) => widget.controller.onSaved(value),
|
||||||
validator: (value) => widget.controller.onValidate(value, _),
|
validator: (value) => widget.controller.onValidate(value, _),
|
||||||
|
onChanged: (value) => widget.controller.onChanged?.call(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: widget.label ?? const Text("Password"),
|
label: widget.label ?? const Text("Password"),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
|
|
|
@ -7,10 +7,10 @@ import '../../../../flutter_form.dart';
|
||||||
/// Input for plain text input used in a [FlutterForm].
|
/// Input for plain text input used in a [FlutterForm].
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputPlainTextController].
|
/// Standard controller is [FlutterFormInputPlainTextController].
|
||||||
class FlutterFormInputPlainText extends FlutterFormInputWidget {
|
class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
|
||||||
const FlutterFormInputPlainText({
|
const FlutterFormInputPlainText({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<String> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
this.decoration,
|
this.decoration,
|
||||||
this.textAlignVertical,
|
this.textAlignVertical,
|
||||||
|
@ -41,6 +41,7 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget {
|
||||||
initialValue: controller.value,
|
initialValue: controller.value,
|
||||||
onSaved: (value) => controller.onSaved(value),
|
onSaved: (value) => controller.onSaved(value),
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
|
onChanged: (value) => controller.onChanged?.call(value),
|
||||||
decoration: inputDecoration,
|
decoration: inputDecoration,
|
||||||
textAlignVertical: textAlignVertical,
|
textAlignVertical: textAlignVertical,
|
||||||
expands: expands,
|
expands: expands,
|
||||||
|
@ -66,7 +67,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
this.maxCharacters,
|
this.maxCharacters,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final FlutterFormInputController controller;
|
final FlutterFormInputController<String> controller;
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
|
||||||
final String? hint;
|
final String? hint;
|
||||||
|
@ -114,6 +115,7 @@ class FlutterFormInputPlainTextController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -126,13 +128,16 @@ class FlutterFormInputPlainTextController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageTitle;
|
String Function(String? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(String value)? checkPageDescription;
|
String Function(String? value)? checkPageDescription;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(String value) {
|
void Function(String? value)? onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onSaved(String? value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ import '../../../../../flutter_form.dart';
|
||||||
/// Input for a number value between two values via a slider. Used in a [FlutterForm].
|
/// Input for a number value between two values via a slider. Used in a [FlutterForm].
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputSliderController].
|
/// Standard controller is [FlutterFormInputSliderController].
|
||||||
class FlutterFormInputSlider extends FlutterFormInputWidget {
|
class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
|
||||||
const FlutterFormInputSlider({
|
const FlutterFormInputSlider({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController<double> controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
this.minValue = 0,
|
this.minValue = 0,
|
||||||
this.maxValue = 100,
|
this.maxValue = 100,
|
||||||
|
@ -46,6 +46,7 @@ class FlutterFormInputSliderController
|
||||||
this.value,
|
this.value,
|
||||||
this.checkPageTitle,
|
this.checkPageTitle,
|
||||||
this.checkPageDescription,
|
this.checkPageDescription,
|
||||||
|
this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -58,18 +59,21 @@ class FlutterFormInputSliderController
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(double value)? checkPageTitle;
|
String Function(double? value)? checkPageTitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String Function(double value)? checkPageDescription;
|
String Function(double? value)? checkPageDescription;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSaved(double value) {
|
void Function(double? value)? onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onSaved(double? value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? onValidate(double value,
|
String? onValidate(double? value,
|
||||||
String Function(String, {List<String>? params}) translator) {
|
String Function(String, {List<String>? params}) translator) {
|
||||||
if (mandatory) {}
|
if (mandatory) {}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ class SliderFormField extends FormField<double> {
|
||||||
Key? key,
|
Key? key,
|
||||||
required FormFieldSetter<double> onSaved,
|
required FormFieldSetter<double> onSaved,
|
||||||
required FormFieldValidator<double> validator,
|
required FormFieldValidator<double> validator,
|
||||||
|
void Function(double value)? onChanged,
|
||||||
double initialValue = 0.5,
|
double initialValue = 0.5,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -16,6 +17,8 @@ class SliderFormField extends FormField<double> {
|
||||||
return Slider(
|
return Slider(
|
||||||
value: state.value ?? initialValue,
|
value: state.value ?? initialValue,
|
||||||
onChanged: (double value) {
|
onChanged: (double value) {
|
||||||
|
onChanged?.call(value);
|
||||||
|
|
||||||
state.didChange(value);
|
state.didChange(value);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,9 +17,6 @@ dependencies:
|
||||||
flutter_riverpod: ^1.0.4
|
flutter_riverpod: ^1.0.4
|
||||||
localization: ^2.1.0
|
localization: ^2.1.0
|
||||||
|
|
||||||
sliding_up_panel: ^2.0.0+1
|
|
||||||
uuid: ^3.0.6
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
Loading…
Reference in a new issue