Skip to content

Commit b03766c

Browse files
authored
Merge pull request #367 from AhmedLSayed9/add_barrier_dismissible_to_dropdown_form_field
Add barrier dismissible to dropdown form field
2 parents 48c3da5 + 4a29817 commit b03766c

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

packages/dropdown_button2/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Update SDK constraints: ">=3.4.0 <4.0.0"
1515
- Fix DropdownButtonFormField clips text when large text scale is used [Flutter core].
1616
- Fix DropdownButtonFormField padding when ButtonTheme.alignedDropdown is true [Flutter core].
17+
- Add barrierCoversButton to DropdownButtonFormField2.
1718

1819
## 3.0.0-beta.21
1920

packages/dropdown_button2/lib/src/dropdown_button2.dart

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ class DropdownButton2<T> extends StatefulWidget {
116116
this.customButton,
117117
this.openWithLongPress = false,
118118
this.barrierDismissible = true,
119+
this.barrierCoversButton = true,
119120
this.barrierColor,
120121
this.barrierLabel,
121-
this.barrierCoversButton = true,
122122
this.openDropdownListenable,
123123
// When adding new arguments, consider adding similar arguments to
124124
// DropdownButtonFormField.
@@ -132,37 +132,37 @@ class DropdownButton2<T> extends StatefulWidget {
132132
const DropdownButton2._formField({
133133
super.key,
134134
required this.items,
135-
this.selectedItemBuilder,
135+
required this.selectedItemBuilder,
136136
required this.valueListenable,
137137
required this.multiValueListenable,
138-
this.hint,
139-
this.disabledHint,
138+
required this.hint,
139+
required this.disabledHint,
140140
required this.onChanged,
141-
this.onMenuStateChange,
142-
this.style,
143-
this.underline,
144-
this.isDense = false,
145-
this.isExpanded = false,
146-
this.focusNode,
147-
this.autofocus = false,
148-
this.enableFeedback,
149-
this.alignment = AlignmentDirectional.centerStart,
150-
this.buttonStyleData,
141+
required this.onMenuStateChange,
142+
required this.style,
143+
required this.isDense,
144+
required this.isExpanded,
145+
required this.focusNode,
146+
required this.autofocus,
147+
required this.enableFeedback,
148+
required this.alignment,
149+
required this.buttonStyleData,
151150
required this.iconStyleData,
152151
required this.dropdownStyleData,
153152
required this.menuItemStyleData,
154-
this.dropdownSearchData,
155-
this.dropdownSeparator,
156-
this.customButton,
157-
this.openWithLongPress = false,
158-
this.barrierDismissible = true,
159-
this.barrierColor,
160-
this.barrierCoversButton = true,
161-
this.barrierLabel,
162-
this.openDropdownListenable,
153+
required this.dropdownSearchData,
154+
required this.dropdownSeparator,
155+
required this.customButton,
156+
required this.openWithLongPress,
157+
required this.barrierDismissible,
158+
required this.barrierCoversButton,
159+
required this.barrierColor,
160+
required this.barrierLabel,
161+
required this.openDropdownListenable,
163162
required InputDecoration inputDecoration,
164163
required bool isEmpty,
165-
}) : _inputDecoration = inputDecoration,
164+
}) : underline = null,
165+
_inputDecoration = inputDecoration,
166166
_isEmpty = isEmpty;
167167

168168
/// The list of items the user can select.
@@ -338,6 +338,11 @@ class DropdownButton2<T> extends StatefulWidget {
338338
/// Whether you can dismiss this route by tapping the modal barrier.
339339
final bool barrierDismissible;
340340

341+
/// Specifies whether the modal barrier should cover the dropdown button or not.
342+
///
343+
/// Defaults to true.
344+
final bool barrierCoversButton;
345+
341346
/// The color to use for the modal barrier. If this is null, the barrier will
342347
/// be transparent.
343348
final Color? barrierColor;
@@ -348,11 +353,6 @@ class DropdownButton2<T> extends StatefulWidget {
348353
/// accessibility tools (like VoiceOver on iOS) focus on the barrier.
349354
final String? barrierLabel;
350355

351-
/// Specifies whether the modal barrier should cover the dropdown button or not.
352-
///
353-
/// Defaults to true.
354-
final bool barrierCoversButton;
355-
356356
/// A [Listenable] that can be used to programmatically open the dropdown menu.
357357
///
358358
/// The [openDropdownListenable] allows you to manually open the dropdown by modifying its value.
@@ -985,6 +985,7 @@ class DropdownButtonFormField2<T> extends FormField<T> {
985985
Widget? customButton,
986986
bool openWithLongPress = false,
987987
bool barrierDismissible = true,
988+
bool barrierCoversButton = true,
988989
Color? barrierColor,
989990
String? barrierLabel,
990991
Listenable? openDropdownListenable,
@@ -1056,6 +1057,7 @@ class DropdownButtonFormField2<T> extends FormField<T> {
10561057
customButton: customButton,
10571058
openWithLongPress: openWithLongPress,
10581059
barrierDismissible: barrierDismissible,
1060+
barrierCoversButton: barrierCoversButton,
10591061
barrierColor: barrierColor,
10601062
barrierLabel: barrierLabel,
10611063
openDropdownListenable: openDropdownListenable,

0 commit comments

Comments
 (0)