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 {
190190 this .closeBehavior = DropdownMenuCloseBehavior .all,
191191 this .maxLines = 1 ,
192192 this .textInputAction,
193+ this .restorationId,
193194 }) : assert (filterCallback == null || enableFilter);
194195
195196 /// Determine if the [DropdownMenu] is enabled.
@@ -527,6 +528,9 @@ class DropdownMenu<T> extends StatefulWidget {
527528 /// {@macro flutter.widgets.TextField.textInputAction}
528529 final TextInputAction ? textInputAction;
529530
531+ /// {@macro flutter.material.textfield.restorationId}
532+ final String ? restorationId;
533+
530534 @override
531535 State <DropdownMenu <T >> createState () => _DropdownMenuState <T >();
532536}
@@ -1070,6 +1074,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
10701074 : null ,
10711075 suffixIcon: trailingButton,
10721076 ).applyDefaults (effectiveInputDecorationTheme),
1077+ restorationId: widget.restorationId,
10731078 );
10741079
10751080 // 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() {
42134213
42144214 semantics.dispose ();
42154215 });
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+ });
42164237}
42174238
42184239enum TestMenu {
You can’t perform that action at this time.
0 commit comments