mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 10:53:49 +02:00
feat: add dropdownfield
This commit is contained in:
parent
a9d3a2c751
commit
a88defd186
5 changed files with 175 additions and 2 deletions
|
@ -137,3 +137,8 @@
|
|||
|
||||
## 6.3.2 - May 15th 2024
|
||||
- Loosened the dependency on intl to be more compatible with several Flutter versions
|
||||
|
||||
|
||||
## 6.4.0 - June 28th 2024
|
||||
- Added `FlutterFormInputDropdown` for dropdown selection
|
||||
- Added style property to `FlutterFormInputEmail`
|
||||
|
|
164
lib/src/widgets/input/input_types/input_dropdown.dart
Normal file
164
lib/src/widgets/input/input_types/input_dropdown.dart
Normal file
|
@ -0,0 +1,164 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_wizard/flutter_form.dart';
|
||||
import 'package:flutter_input_library/flutter_input_library.dart' as input;
|
||||
|
||||
class FlutterFormInputDropdown extends FlutterFormInputWidget<Object> {
|
||||
const FlutterFormInputDropdown({
|
||||
required super.controller,
|
||||
required this.validationMessage,
|
||||
this.items,
|
||||
this.selectedItemBuilder,
|
||||
this.value,
|
||||
this.hint,
|
||||
this.disabledHint,
|
||||
this.onChanged,
|
||||
this.onTap,
|
||||
this.elevation = 8,
|
||||
this.style,
|
||||
this.icon,
|
||||
this.iconDisabledColor,
|
||||
this.iconEnabledColor,
|
||||
this.iconSize = 24.0,
|
||||
this.isDense = false,
|
||||
this.isExpanded = false,
|
||||
this.itemHeight,
|
||||
this.focusColor,
|
||||
this.autofocus = false,
|
||||
this.dropdownColor,
|
||||
this.decoration,
|
||||
this.onSaved,
|
||||
this.validator,
|
||||
this.autovalidateMode,
|
||||
this.menuMaxHeight,
|
||||
this.enableFeedback,
|
||||
this.alignment = Alignment.centerLeft,
|
||||
this.borderRadius,
|
||||
this.padding,
|
||||
super.key,
|
||||
super.focusNode,
|
||||
super.label,
|
||||
});
|
||||
|
||||
final List<DropdownMenuItem<Object?>>? items;
|
||||
final List<Widget> Function(BuildContext)? selectedItemBuilder;
|
||||
final Object? value;
|
||||
final Widget? hint;
|
||||
final Widget? disabledHint;
|
||||
final void Function(Object?)? onChanged;
|
||||
final void Function()? onTap;
|
||||
final int elevation;
|
||||
final TextStyle? style;
|
||||
final Widget? icon;
|
||||
final Color? iconDisabledColor;
|
||||
final Color? iconEnabledColor;
|
||||
final double iconSize;
|
||||
final bool isDense;
|
||||
final bool isExpanded;
|
||||
final double? itemHeight;
|
||||
final Color? focusColor;
|
||||
final bool autofocus;
|
||||
final Color? dropdownColor;
|
||||
final InputDecoration? decoration;
|
||||
final void Function(Object?)? onSaved;
|
||||
final String? Function(Object?)? validator;
|
||||
final AutovalidateMode? autovalidateMode;
|
||||
final double? menuMaxHeight;
|
||||
final bool? enableFeedback;
|
||||
final AlignmentGeometry alignment;
|
||||
final BorderRadius? borderRadius;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final String validationMessage;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.registerController(context);
|
||||
return input.FlutterFormInputDropdown(
|
||||
items: items,
|
||||
selectedItemBuilder: selectedItemBuilder,
|
||||
value: value,
|
||||
hint: hint,
|
||||
disabledHint: disabledHint,
|
||||
onChanged: controller.onChanged,
|
||||
onTap: () => onTap?.call(),
|
||||
elevation: elevation,
|
||||
style: style,
|
||||
icon: icon,
|
||||
iconDisabledColor: iconDisabledColor,
|
||||
iconEnabledColor: iconEnabledColor,
|
||||
iconSize: iconSize,
|
||||
isDense: isDense,
|
||||
isExpanded: isExpanded,
|
||||
itemHeight: itemHeight,
|
||||
focusColor: focusColor,
|
||||
focusNode: focusNode,
|
||||
autofocus: autofocus,
|
||||
dropdownColor: dropdownColor,
|
||||
decoration: decoration,
|
||||
onSaved: controller.onSaved,
|
||||
validator: validator ??
|
||||
(value) => controller.onValidate(
|
||||
value,
|
||||
validationMessage,
|
||||
),
|
||||
autovalidateMode: autovalidateMode,
|
||||
menuMaxHeight: menuMaxHeight,
|
||||
enableFeedback: enableFeedback,
|
||||
alignment: alignment,
|
||||
borderRadius: borderRadius,
|
||||
padding: padding,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FlutterFormInputDropdownController
|
||||
implements FlutterFormInputController<Object> {
|
||||
FlutterFormInputDropdownController({
|
||||
required this.id,
|
||||
this.mandatory = false,
|
||||
this.value,
|
||||
this.checkPageTitle,
|
||||
this.checkPageDescription,
|
||||
this.onChanged,
|
||||
this.onSubmit,
|
||||
});
|
||||
|
||||
@override
|
||||
String? id;
|
||||
|
||||
@override
|
||||
Object? value;
|
||||
|
||||
@override
|
||||
bool mandatory;
|
||||
|
||||
@override
|
||||
String Function(Object? value)? checkPageTitle;
|
||||
|
||||
@override
|
||||
String Function(Object? value)? checkPageDescription;
|
||||
|
||||
@override
|
||||
void Function(Object? value)? onChanged;
|
||||
|
||||
@override
|
||||
void Function(Object? value)? onSubmit;
|
||||
|
||||
@override
|
||||
void onSaved(Object? value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@override
|
||||
String? onValidate(
|
||||
Object? value,
|
||||
String validationMessage,
|
||||
) {
|
||||
if (mandatory) {
|
||||
if (value == null) {
|
||||
return validationMessage;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
|||
bool? enabled,
|
||||
this.validator,
|
||||
this.decoration,
|
||||
this.style,
|
||||
}) : super(
|
||||
enabled: enabled ?? true,
|
||||
);
|
||||
|
@ -30,12 +31,14 @@ class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
|||
final InputDecoration? decoration;
|
||||
final String validationMessage;
|
||||
final String? Function(String?)? validator;
|
||||
final TextStyle? style;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.registerController(context);
|
||||
|
||||
return input.FlutterFormInputPlainText(
|
||||
style: style,
|
||||
enabled: enabled,
|
||||
initialValue: controller.value,
|
||||
onSaved: (value) {
|
||||
|
|
|
@ -7,6 +7,7 @@ export 'package:flutter_input_library/flutter_input_library.dart'
|
|||
|
||||
export 'input_carousel/input_carousel.dart';
|
||||
export 'input_date_picker/input_date_picker.dart';
|
||||
export 'input_dropdown.dart';
|
||||
export 'input_email.dart';
|
||||
export 'input_number_picker/input_number_picker.dart';
|
||||
export 'input_password/input_password.dart';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_form_wizard
|
||||
description: A new Flutter package project.
|
||||
version: 6.3.2
|
||||
version: 6.4.0
|
||||
homepage: https://github.com/Iconica-Development/flutter_form_wizard
|
||||
|
||||
publish_to: none
|
||||
|
@ -18,7 +18,7 @@ dependencies:
|
|||
flutter_input_library:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_input_library
|
||||
ref: 3.3.1
|
||||
ref: 3.4.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in a new issue