Add FocusNode option to inputs

This commit is contained in:
Thomas Klein Langenhorst 2023-01-12 14:12:45 +01:00
parent b27d5ccd44
commit 09a1171e8b
10 changed files with 45 additions and 10 deletions

View file

@ -46,4 +46,8 @@
## 5.0.0 - November 29th 2022 ## 5.0.0 - November 29th 2022
- `flutter_input_library` now enforces 24h time requirements - `flutter_input_library` now enforces 24h time requirements
## 5.0.3 - January 12th 2023
- Add FocusNode option to inputs

View file

@ -61,16 +61,16 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "5.0.1" version: "5.0.2"
flutter_input_library: flutter_input_library:
dependency: transitive dependency: transitive
description: description:
path: "." path: "."
ref: "1.0.1" ref: "1.0.2"
resolved-ref: "5afec9410503358c354d9324666a4eb11acbedb2" resolved-ref: ab6d840c0d326b1b1d5f738b2c7360a841d01015
url: "https://github.com/Iconica-Development/flutter_input_library" url: "https://github.com/Iconica-Development/flutter_input_library"
source: git source: git
version: "1.0.0" version: "1.0.2"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:

View file

@ -18,6 +18,7 @@ abstract class FlutterFormInputWidget<T> extends ConsumerWidget {
const FlutterFormInputWidget({ const FlutterFormInputWidget({
Key? key, Key? key,
required this.controller, required this.controller,
this.focusNode,
this.label, this.label,
String? hintText, String? hintText,
}) : super(key: key); }) : super(key: key);
@ -28,6 +29,8 @@ abstract class FlutterFormInputWidget<T> extends ConsumerWidget {
/// [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;
final FocusNode? focusNode;
/// [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.
registerController(BuildContext context) { registerController(BuildContext context) {
FlutterFormInputController? localController = FlutterFormInputController? localController =

View file

@ -16,10 +16,12 @@ class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
const FlutterFormInputEmail({ const FlutterFormInputEmail({
Key? key, Key? key,
required FlutterFormInputController<String> controller, required FlutterFormInputController<String> controller,
FocusNode? focusNode,
Widget? label, Widget? label,
}) : super( }) : super(
key: key, key: key,
controller: controller, controller: controller,
focusNode: focusNode,
label: label, label: label,
); );
@ -35,6 +37,7 @@ class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
onSaved: (value) { onSaved: (value) {
controller.onSaved(value); controller.onSaved(value);
}, },
focusNode: focusNode,
validator: (value) => controller.onValidate(value, _), validator: (value) => controller.onValidate(value, _),
onChanged: (value) => controller.onChanged?.call(value), onChanged: (value) => controller.onChanged?.call(value),
decoration: InputDecoration( decoration: InputDecoration(

View file

@ -19,6 +19,7 @@ class FlutterFormInputNumberPicker extends FlutterFormInputWidget<int> {
Key? key, Key? key,
required FlutterFormInputController<int> controller, required FlutterFormInputController<int> controller,
Widget? label, Widget? label,
FocusNode? focusNode,
this.minValue = 0, this.minValue = 0,
this.maxValue = 100, this.maxValue = 100,
}) : assert(minValue < maxValue), }) : assert(minValue < maxValue),

View file

@ -15,8 +15,13 @@ class FlutterFormInputPassword extends FlutterFormInputWidget<String> {
const FlutterFormInputPassword({ const FlutterFormInputPassword({
Key? key, Key? key,
required FlutterFormInputController<String> controller, required FlutterFormInputController<String> controller,
FocusNode? focusNode,
Widget? label, Widget? label,
}) : super(key: key, controller: controller, label: label); }) : super(
key: key,
controller: controller,
focusNode: focusNode,
label: label);
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@ -27,6 +32,7 @@ class FlutterFormInputPassword extends FlutterFormInputWidget<String> {
return input.FlutterFormInputPassword( return input.FlutterFormInputPassword(
initialValue: controller.value, initialValue: controller.value,
focusNode: focusNode,
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), onChanged: (value) => controller.onChanged?.call(value),

View file

@ -16,6 +16,7 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
const FlutterFormInputPlainText({ const FlutterFormInputPlainText({
Key? key, Key? key,
required FlutterFormInputController<String> controller, required FlutterFormInputController<String> controller,
FocusNode? focusNode,
Widget? label, Widget? label,
this.decoration, this.decoration,
this.textAlignVertical, this.textAlignVertical,
@ -24,7 +25,11 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
this.scrollPadding, this.scrollPadding,
this.maxLength, this.maxLength,
this.keyboardType, this.keyboardType,
}) : super(key: key, controller: controller, label: label); }) : super(
key: key,
controller: controller,
focusNode: focusNode,
label: label);
final InputDecoration? decoration; final InputDecoration? decoration;
final TextAlignVertical? textAlignVertical; final TextAlignVertical? textAlignVertical;
@ -49,6 +54,7 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
return input.FlutterFormInputPlainText( return input.FlutterFormInputPlainText(
scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0), scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0),
initialValue: controller.value, initialValue: controller.value,
focusNode: focusNode,
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), onChanged: (value) => controller.onChanged?.call(value),

View file

@ -16,11 +16,16 @@ class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
const FlutterFormInputSlider({ const FlutterFormInputSlider({
Key? key, Key? key,
required FlutterFormInputController<double> controller, required FlutterFormInputController<double> controller,
FocusNode? focusNode,
Widget? label, Widget? label,
this.minValue = 0, this.minValue = 0,
this.maxValue = 100, this.maxValue = 100,
}) : assert(minValue < maxValue), }) : assert(minValue < maxValue),
super(key: key, controller: controller, label: label); super(
key: key,
controller: controller,
focusNode: focusNode,
label: label);
final int minValue; final int minValue;
final int maxValue; final int maxValue;
@ -33,6 +38,7 @@ class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
super.registerController(context); super.registerController(context);
return input.FlutterFormInputSlider( return input.FlutterFormInputSlider(
focusNode: focusNode,
onSaved: (value) => controller.onSaved(value), onSaved: (value) => controller.onSaved(value),
validator: (value) => controller.onValidate(value, _), validator: (value) => controller.onValidate(value, _),
); );

View file

@ -15,8 +15,13 @@ class FlutterFormInputSwitch extends FlutterFormInputWidget<bool> {
const FlutterFormInputSwitch({ const FlutterFormInputSwitch({
Key? key, Key? key,
required FlutterFormInputController<bool> controller, required FlutterFormInputController<bool> controller,
FocusNode? focusNode,
Widget? label, Widget? label,
}) : super(key: key, controller: controller, label: label); }) : super(
key: key,
controller: controller,
focusNode: focusNode,
label: label);
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@ -26,6 +31,7 @@ class FlutterFormInputSwitch extends FlutterFormInputWidget<bool> {
super.registerController(context); super.registerController(context);
return input.FlutterFormInputSwitch( return input.FlutterFormInputSwitch(
focusNode: focusNode,
onSaved: (value) => controller.onSaved(value), onSaved: (value) => controller.onSaved(value),
onChanged: controller.onChanged, onChanged: controller.onChanged,
validator: (value) => controller.onValidate(value, _), validator: (value) => controller.onValidate(value, _),

View file

@ -1,6 +1,6 @@
name: flutter_form_wizard name: flutter_form_wizard
description: A new Flutter package project. description: A new Flutter package project.
version: 5.0.2 version: 5.0.3
homepage: https://github.com/Iconica-Development/flutter_form_wizard homepage: https://github.com/Iconica-Development/flutter_form_wizard
publish_to: none publish_to: none