mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-19 01:13:45 +02:00
Merge pull request #6 from Iconica-Development/feature/add_focus
Feature/add focus
This commit is contained in:
commit
e178f6da67
8 changed files with 28 additions and 2 deletions
|
@ -9,3 +9,7 @@
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
* add decoration option for datetime input fields
|
* add decoration option for datetime input fields
|
||||||
|
|
||||||
|
## 1.0.2
|
||||||
|
|
||||||
|
* add FocusNode option for input fields
|
|
@ -16,6 +16,7 @@ class FlutterFormInputSlider extends ConsumerWidget {
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.validator,
|
this.validator,
|
||||||
|
this.focusNode,
|
||||||
}) : assert(minValue < maxValue),
|
}) : assert(minValue < maxValue),
|
||||||
super(
|
super(
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -27,6 +28,7 @@ class FlutterFormInputSlider extends ConsumerWidget {
|
||||||
final String? Function(double?)? validator;
|
final String? Function(double?)? validator;
|
||||||
final double? initialValue;
|
final double? initialValue;
|
||||||
final Function(double?)? onChanged;
|
final Function(double?)? onChanged;
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
@ -35,6 +37,7 @@ class FlutterFormInputSlider extends ConsumerWidget {
|
||||||
validator: (value) => validator?.call(value),
|
validator: (value) => validator?.call(value),
|
||||||
onChanged: (value) => onChanged?.call(value),
|
onChanged: (value) => onChanged?.call(value),
|
||||||
initialValue: initialValue ?? 0.5,
|
initialValue: initialValue ?? 0.5,
|
||||||
|
focusNode: focusNode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ class SliderFormField extends FormField<double> {
|
||||||
required FormFieldSetter<double> onSaved,
|
required FormFieldSetter<double> onSaved,
|
||||||
required FormFieldValidator<double> validator,
|
required FormFieldValidator<double> validator,
|
||||||
void Function(double value)? onChanged,
|
void Function(double value)? onChanged,
|
||||||
|
FocusNode? focusNode,
|
||||||
double initialValue = 0.5,
|
double initialValue = 0.5,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -20,6 +21,7 @@ class SliderFormField extends FormField<double> {
|
||||||
builder: (FormFieldState<double> state) {
|
builder: (FormFieldState<double> state) {
|
||||||
return Slider(
|
return Slider(
|
||||||
value: state.value ?? initialValue,
|
value: state.value ?? initialValue,
|
||||||
|
focusNode: focusNode,
|
||||||
onChanged: (double value) {
|
onChanged: (double value) {
|
||||||
onChanged?.call(value);
|
onChanged?.call(value);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
||||||
final String? Function(bool?)? validator;
|
final String? Function(bool?)? validator;
|
||||||
final Function(bool?)? onChanged;
|
final Function(bool?)? onChanged;
|
||||||
final bool? initialValue;
|
final bool? initialValue;
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
const FlutterFormInputSwitch({
|
const FlutterFormInputSwitch({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -21,6 +22,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
||||||
this.onSaved,
|
this.onSaved,
|
||||||
this.validator,
|
this.validator,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.focusNode,
|
||||||
this.initialValue = false,
|
this.initialValue = false,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -33,6 +35,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
||||||
onChanged: (value) => onChanged?.call(value),
|
onChanged: (value) => onChanged?.call(value),
|
||||||
validator: (value) => validator?.call(value),
|
validator: (value) => validator?.call(value),
|
||||||
initialValue: initialValue ?? false,
|
initialValue: initialValue ?? false,
|
||||||
|
focusNode: focusNode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ class SwitchFormField extends FormField<bool> {
|
||||||
Key? key,
|
Key? key,
|
||||||
required FormFieldSetter<bool> onSaved,
|
required FormFieldSetter<bool> onSaved,
|
||||||
required FormFieldValidator<bool> validator,
|
required FormFieldValidator<bool> validator,
|
||||||
|
FocusNode? focusNode,
|
||||||
bool initialValue = false,
|
bool initialValue = false,
|
||||||
bool autovalidate = false,
|
bool autovalidate = false,
|
||||||
void Function(bool? value)? onChanged,
|
void Function(bool? value)? onChanged,
|
||||||
|
@ -21,6 +22,7 @@ class SwitchFormField extends FormField<bool> {
|
||||||
return SwitchWidget(
|
return SwitchWidget(
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
state: state,
|
state: state,
|
||||||
|
focusNode: focusNode,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -31,11 +33,13 @@ class SwitchWidget extends StatefulWidget {
|
||||||
this.initialValue = false,
|
this.initialValue = false,
|
||||||
required this.state,
|
required this.state,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.focusNode,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool initialValue;
|
final bool initialValue;
|
||||||
final FormFieldState<bool> state;
|
final FormFieldState<bool> state;
|
||||||
|
final FocusNode? focusNode;
|
||||||
final void Function(bool? value)? onChanged;
|
final void Function(bool? value)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -49,6 +53,7 @@ class _SwitchWidgetState extends State<SwitchWidget> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Switch(
|
return Switch(
|
||||||
value: value,
|
value: value,
|
||||||
|
focusNode: widget.focusNode,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool value) {
|
||||||
widget.onChanged?.call(value);
|
widget.onChanged?.call(value);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
/// as the [controller] parameter and an optional [Widget] as [label]
|
/// as the [controller] parameter and an optional [Widget] as [label]
|
||||||
class FlutterFormInputPassword extends ConsumerStatefulWidget {
|
class FlutterFormInputPassword extends ConsumerStatefulWidget {
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
final FocusNode? focusNode;
|
||||||
final String? initialValue;
|
final String? initialValue;
|
||||||
final Function(String?)? onSaved;
|
final Function(String?)? onSaved;
|
||||||
final String? Function(String?)? validator;
|
final String? Function(String?)? validator;
|
||||||
|
@ -18,6 +19,7 @@ class FlutterFormInputPassword extends ConsumerStatefulWidget {
|
||||||
const FlutterFormInputPassword({
|
const FlutterFormInputPassword({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.label,
|
this.label,
|
||||||
|
this.focusNode,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.onSaved,
|
this.onSaved,
|
||||||
this.validator,
|
this.validator,
|
||||||
|
@ -38,6 +40,7 @@ class _PasswordTextFieldState extends ConsumerState<FlutterFormInputPassword> {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
obscureText: obscured,
|
obscureText: obscured,
|
||||||
|
focusNode: widget.focusNode,
|
||||||
onSaved: (value) => widget.onSaved?.call(value),
|
onSaved: (value) => widget.onSaved?.call(value),
|
||||||
validator: (value) => widget.validator?.call(value),
|
validator: (value) => widget.validator?.call(value),
|
||||||
onChanged: (value) => widget.onChanged?.call(value),
|
onChanged: (value) => widget.onChanged?.call(value),
|
||||||
|
|
|
@ -10,6 +10,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
||||||
const FlutterFormInputPlainText({
|
const FlutterFormInputPlainText({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.label,
|
this.label,
|
||||||
|
this.focusNode,
|
||||||
this.decoration,
|
this.decoration,
|
||||||
this.textAlignVertical,
|
this.textAlignVertical,
|
||||||
this.expands = false,
|
this.expands = false,
|
||||||
|
@ -35,6 +36,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
||||||
final EdgeInsets? scrollPadding;
|
final EdgeInsets? scrollPadding;
|
||||||
final TextInputType? keyboardType;
|
final TextInputType? keyboardType;
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
final FocusNode? focusNode;
|
||||||
final String? initialValue;
|
final String? initialValue;
|
||||||
final Function(String?)? onSaved;
|
final Function(String?)? onSaved;
|
||||||
final String? Function(String?)? validator;
|
final String? Function(String?)? validator;
|
||||||
|
@ -53,6 +55,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
||||||
style: style,
|
style: style,
|
||||||
scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0),
|
scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0),
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
|
focusNode: focusNode,
|
||||||
onSaved: (value) => onSaved?.call(value),
|
onSaved: (value) => onSaved?.call(value),
|
||||||
validator: (value) => validator?.call(value),
|
validator: (value) => validator?.call(value),
|
||||||
onChanged: (value) => onChanged?.call(value),
|
onChanged: (value) => onChanged?.call(value),
|
||||||
|
@ -71,6 +74,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
const FlutterFormInputMultiLine({
|
const FlutterFormInputMultiLine({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.label,
|
this.label,
|
||||||
|
this.focusNode,
|
||||||
this.hint,
|
this.hint,
|
||||||
this.maxCharacters,
|
this.maxCharacters,
|
||||||
this.scrollPadding,
|
this.scrollPadding,
|
||||||
|
@ -84,6 +88,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
final FocusNode? focusNode;
|
||||||
final String? hint;
|
final String? hint;
|
||||||
final int? maxCharacters;
|
final int? maxCharacters;
|
||||||
|
|
||||||
|
@ -106,6 +111,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
textAlignVertical: TextAlignVertical.top,
|
textAlignVertical: TextAlignVertical.top,
|
||||||
expands: true,
|
expands: true,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
|
focusNode: focusNode,
|
||||||
maxLength: maxCharacters,
|
maxLength: maxCharacters,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
scrollPadding: scrollPadding,
|
scrollPadding: scrollPadding,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_input_library
|
name: flutter_input_library
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 1.0.1
|
version: 1.0.2
|
||||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue