From d74c702fa7fcf366136c2093da3d5da3ed3dc16d Mon Sep 17 00:00:00 2001 From: mike doornenbal Date: Fri, 28 Jun 2024 14:17:18 +0200 Subject: [PATCH] feat: add FlutterFormInputDropdown --- CHANGELOG.md | 3 + lib/src/inputs/dropdown/dropdown.dart | 99 +++++++++++++++++++++++++++ lib/src/inputs/inputs.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 lib/src/inputs/dropdown/dropdown.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ee998..eb7e9db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,3 +84,6 @@ ## 3.3.1 * Loosened the dependen on intl to be more compatible with several Flutter versions + +## 3.4.0 +* Added `FlutterFormInputDropdown` diff --git a/lib/src/inputs/dropdown/dropdown.dart b/lib/src/inputs/dropdown/dropdown.dart new file mode 100644 index 0000000..567b5b3 --- /dev/null +++ b/lib/src/inputs/dropdown/dropdown.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; + +class FlutterFormInputDropdown extends StatelessWidget { + const FlutterFormInputDropdown({ + this.alignment = AlignmentDirectional.centerStart, + this.autofocus = false, + this.isExpanded = false, + this.isDense = true, + this.iconSize = 24, + this.elevation = 8, + this.items, + this.selectedItemBuilder, + this.value, + this.hint, + this.disabledHint, + this.onChanged, + this.onTap, + this.style, + this.icon, + this.iconDisabledColor, + this.iconEnabledColor, + this.itemHeight, + this.focusColor, + this.focusNode, + this.dropdownColor, + this.decoration, + this.onSaved, + this.validator, + this.autovalidateMode, + this.menuMaxHeight, + this.enableFeedback, + this.borderRadius, + this.padding, + super.key, + }); + + final List>? items; + final List 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 FocusNode? focusNode; + 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; + + @override + Widget build(BuildContext context) => DropdownButtonFormField( + items: items, + selectedItemBuilder: selectedItemBuilder, + value: value, + hint: hint, + disabledHint: disabledHint, + onChanged: (value) => onChanged?.call(value), + 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: (value) => onSaved?.call(value), + validator: (value) => validator?.call(value), + autovalidateMode: autovalidateMode, + menuMaxHeight: menuMaxHeight, + enableFeedback: enableFeedback, + alignment: alignment, + borderRadius: borderRadius, + padding: padding, + ); +} diff --git a/lib/src/inputs/inputs.dart b/lib/src/inputs/inputs.dart index f3671d9..fbaf5bb 100644 --- a/lib/src/inputs/inputs.dart +++ b/lib/src/inputs/inputs.dart @@ -1,6 +1,7 @@ export 'bool/bool.dart'; export 'carousel/carousel.dart'; export 'date_picker/date_picker.dart'; +export 'dropdown/dropdown.dart'; export 'number_picker/number_picker.dart'; export 'phone/countries.dart'; export 'phone/phone.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 6367f49..f6b3ffb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_input_library description: A new Flutter package project. -version: 3.3.1 +version: 3.4.0 repository: https://github.com/Iconica-Development/flutter_input_library environment: