File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ class DropdownMenu<T> extends StatefulWidget {
190
190
this .closeBehavior = DropdownMenuCloseBehavior .all,
191
191
this .maxLines = 1 ,
192
192
this .textInputAction,
193
+ this .restorationId,
193
194
}) : assert (filterCallback == null || enableFilter);
194
195
195
196
/// Determine if the [DropdownMenu] is enabled.
@@ -527,6 +528,9 @@ class DropdownMenu<T> extends StatefulWidget {
527
528
/// {@macro flutter.widgets.TextField.textInputAction}
528
529
final TextInputAction ? textInputAction;
529
530
531
+ /// {@macro flutter.material.textfield.restorationId}
532
+ final String ? restorationId;
533
+
530
534
@override
531
535
State <DropdownMenu <T >> createState () => _DropdownMenuState <T >();
532
536
}
@@ -1070,6 +1074,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
1070
1074
: null ,
1071
1075
suffixIcon: trailingButton,
1072
1076
).applyDefaults (effectiveInputDecorationTheme),
1077
+ restorationId: widget.restorationId,
1073
1078
);
1074
1079
1075
1080
// If [expandedInsets] is not null, the width of the text field should depend
Original file line number Diff line number Diff line change @@ -4213,6 +4213,27 @@ void main() {
4213
4213
4214
4214
semantics.dispose ();
4215
4215
});
4216
+
4217
+ testWidgets ('restorationId is passed to inner TextField' , (WidgetTester tester) async {
4218
+ const String restorationId = 'dropdown_menu' ;
4219
+
4220
+ await tester.pumpWidget (
4221
+ MaterialApp (
4222
+ home: Scaffold (
4223
+ body: DropdownMenu <TestMenu >(
4224
+ dropdownMenuEntries: menuChildren,
4225
+ requestFocusOnTap: true ,
4226
+ restorationId: restorationId,
4227
+ ),
4228
+ ),
4229
+ ),
4230
+ );
4231
+
4232
+ expect (find.byType (TextField ), findsOne);
4233
+
4234
+ final TextField textField = tester.firstWidget (find.byType (TextField ));
4235
+ expect (textField.restorationId, restorationId);
4236
+ });
4216
4237
}
4217
4238
4218
4239
enum TestMenu {
You can’t perform that action at this time.
0 commit comments