mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03: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
|
@ -8,4 +8,8 @@
|
|||
|
||||
## 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.initialValue,
|
||||
this.validator,
|
||||
this.focusNode,
|
||||
}) : assert(minValue < maxValue),
|
||||
super(
|
||||
key: key,
|
||||
|
@ -27,6 +28,7 @@ class FlutterFormInputSlider extends ConsumerWidget {
|
|||
final String? Function(double?)? validator;
|
||||
final double? initialValue;
|
||||
final Function(double?)? onChanged;
|
||||
final FocusNode? focusNode;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
|
@ -35,6 +37,7 @@ class FlutterFormInputSlider extends ConsumerWidget {
|
|||
validator: (value) => validator?.call(value),
|
||||
onChanged: (value) => onChanged?.call(value),
|
||||
initialValue: initialValue ?? 0.5,
|
||||
focusNode: focusNode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ class SliderFormField extends FormField<double> {
|
|||
required FormFieldSetter<double> onSaved,
|
||||
required FormFieldValidator<double> validator,
|
||||
void Function(double value)? onChanged,
|
||||
FocusNode? focusNode,
|
||||
double initialValue = 0.5,
|
||||
}) : super(
|
||||
key: key,
|
||||
|
@ -20,6 +21,7 @@ class SliderFormField extends FormField<double> {
|
|||
builder: (FormFieldState<double> state) {
|
||||
return Slider(
|
||||
value: state.value ?? initialValue,
|
||||
focusNode: focusNode,
|
||||
onChanged: (double value) {
|
||||
onChanged?.call(value);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
|||
final String? Function(bool?)? validator;
|
||||
final Function(bool?)? onChanged;
|
||||
final bool? initialValue;
|
||||
final FocusNode? focusNode;
|
||||
|
||||
const FlutterFormInputSwitch({
|
||||
Key? key,
|
||||
|
@ -21,6 +22,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
|||
this.onSaved,
|
||||
this.validator,
|
||||
this.onChanged,
|
||||
this.focusNode,
|
||||
this.initialValue = false,
|
||||
}) : super(
|
||||
key: key,
|
||||
|
@ -33,6 +35,7 @@ class FlutterFormInputSwitch extends ConsumerWidget {
|
|||
onChanged: (value) => onChanged?.call(value),
|
||||
validator: (value) => validator?.call(value),
|
||||
initialValue: initialValue ?? false,
|
||||
focusNode: focusNode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ class SwitchFormField extends FormField<bool> {
|
|||
Key? key,
|
||||
required FormFieldSetter<bool> onSaved,
|
||||
required FormFieldValidator<bool> validator,
|
||||
FocusNode? focusNode,
|
||||
bool initialValue = false,
|
||||
bool autovalidate = false,
|
||||
void Function(bool? value)? onChanged,
|
||||
|
@ -21,6 +22,7 @@ class SwitchFormField extends FormField<bool> {
|
|||
return SwitchWidget(
|
||||
initialValue: initialValue,
|
||||
state: state,
|
||||
focusNode: focusNode,
|
||||
onChanged: onChanged,
|
||||
);
|
||||
});
|
||||
|
@ -31,11 +33,13 @@ class SwitchWidget extends StatefulWidget {
|
|||
this.initialValue = false,
|
||||
required this.state,
|
||||
this.onChanged,
|
||||
this.focusNode,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final bool initialValue;
|
||||
final FormFieldState<bool> state;
|
||||
final FocusNode? focusNode;
|
||||
final void Function(bool? value)? onChanged;
|
||||
|
||||
@override
|
||||
|
@ -49,6 +53,7 @@ class _SwitchWidgetState extends State<SwitchWidget> {
|
|||
Widget build(BuildContext context) {
|
||||
return Switch(
|
||||
value: value,
|
||||
focusNode: widget.focusNode,
|
||||
onChanged: (bool 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]
|
||||
class FlutterFormInputPassword extends ConsumerStatefulWidget {
|
||||
final Widget? label;
|
||||
final FocusNode? focusNode;
|
||||
final String? initialValue;
|
||||
final Function(String?)? onSaved;
|
||||
final String? Function(String?)? validator;
|
||||
|
@ -18,6 +19,7 @@ class FlutterFormInputPassword extends ConsumerStatefulWidget {
|
|||
const FlutterFormInputPassword({
|
||||
Key? key,
|
||||
this.label,
|
||||
this.focusNode,
|
||||
this.initialValue,
|
||||
this.onSaved,
|
||||
this.validator,
|
||||
|
@ -38,6 +40,7 @@ class _PasswordTextFieldState extends ConsumerState<FlutterFormInputPassword> {
|
|||
return TextFormField(
|
||||
initialValue: widget.initialValue,
|
||||
obscureText: obscured,
|
||||
focusNode: widget.focusNode,
|
||||
onSaved: (value) => widget.onSaved?.call(value),
|
||||
validator: (value) => widget.validator?.call(value),
|
||||
onChanged: (value) => widget.onChanged?.call(value),
|
||||
|
|
|
@ -10,6 +10,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
|||
const FlutterFormInputPlainText({
|
||||
Key? key,
|
||||
this.label,
|
||||
this.focusNode,
|
||||
this.decoration,
|
||||
this.textAlignVertical,
|
||||
this.expands = false,
|
||||
|
@ -35,6 +36,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
|||
final EdgeInsets? scrollPadding;
|
||||
final TextInputType? keyboardType;
|
||||
final Widget? label;
|
||||
final FocusNode? focusNode;
|
||||
final String? initialValue;
|
||||
final Function(String?)? onSaved;
|
||||
final String? Function(String?)? validator;
|
||||
|
@ -53,6 +55,7 @@ class FlutterFormInputPlainText extends ConsumerWidget {
|
|||
style: style,
|
||||
scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0),
|
||||
initialValue: initialValue,
|
||||
focusNode: focusNode,
|
||||
onSaved: (value) => onSaved?.call(value),
|
||||
validator: (value) => validator?.call(value),
|
||||
onChanged: (value) => onChanged?.call(value),
|
||||
|
@ -71,6 +74,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
|||
const FlutterFormInputMultiLine({
|
||||
Key? key,
|
||||
this.label,
|
||||
this.focusNode,
|
||||
this.hint,
|
||||
this.maxCharacters,
|
||||
this.scrollPadding,
|
||||
|
@ -84,6 +88,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
final Widget? label;
|
||||
final FocusNode? focusNode;
|
||||
final String? hint;
|
||||
final int? maxCharacters;
|
||||
|
||||
|
@ -106,6 +111,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
|||
textAlignVertical: TextAlignVertical.top,
|
||||
expands: true,
|
||||
maxLines: null,
|
||||
focusNode: focusNode,
|
||||
maxLength: maxCharacters,
|
||||
initialValue: initialValue,
|
||||
scrollPadding: scrollPadding,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_input_library
|
||||
description: A new Flutter package project.
|
||||
version: 1.0.1
|
||||
version: 1.0.2
|
||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue