@@ -84,56 +84,64 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
84
84
children: < Widget > [
85
85
Padding (
86
86
padding: const EdgeInsets .symmetric (vertical: 20 ),
87
- child: Row (
88
- mainAxisAlignment: MainAxisAlignment .center,
89
- children: < Widget > [
90
- DropdownMenu <ColorLabel >(
91
- initialSelection: ColorLabel .green,
92
- controller: colorController,
93
- // requestFocusOnTap is enabled/disabled by platforms when it is null.
94
- // On mobile platforms, this is false by default. Setting this to true will
95
- // trigger focus request on the text field and virtual keyboard will appear
96
- // afterward. On desktop platforms however, this defaults to true.
97
- requestFocusOnTap: true ,
98
- label: const Text ('Color' ),
99
- onSelected: (ColorLabel ? color) {
100
- setState (() {
101
- selectedColor = color;
102
- });
103
- },
104
- dropdownMenuEntries: ColorLabel .entries,
105
- ),
106
- const SizedBox (width: 24 ),
107
- DropdownMenu <IconLabel >(
108
- controller: iconController,
109
- enableFilter: true ,
110
- requestFocusOnTap: true ,
111
- leadingIcon: const Icon (Icons .search),
112
- label: const Text ('Icon' ),
113
- inputDecorationTheme: const InputDecorationTheme (
114
- filled: true ,
115
- contentPadding: EdgeInsets .symmetric (vertical: 5.0 ),
87
+ child: SingleChildScrollView (
88
+ scrollDirection: Axis .horizontal,
89
+ child: Row (
90
+ mainAxisSize: MainAxisSize .min,
91
+ mainAxisAlignment: MainAxisAlignment .center,
92
+ children: < Widget > [
93
+ DropdownMenu <ColorLabel >(
94
+ initialSelection: ColorLabel .green,
95
+ controller: colorController,
96
+ // The default requestFocusOnTap value depends on the platform.
97
+ // On mobile, it defaults to false, and on desktop, it defaults to true.
98
+ // Setting this to true will trigger a focus request on the text field, and
99
+ // the virtual keyboard will appear afterward.
100
+ requestFocusOnTap: true ,
101
+ label: const Text ('Color' ),
102
+ onSelected: (ColorLabel ? color) {
103
+ setState (() {
104
+ selectedColor = color;
105
+ });
106
+ },
107
+ dropdownMenuEntries: ColorLabel .entries,
116
108
),
117
- onSelected: (IconLabel ? icon) {
118
- setState (() {
119
- selectedIcon = icon;
120
- });
121
- },
122
- dropdownMenuEntries: IconLabel .entries,
123
- ),
124
- ],
109
+ const SizedBox (width: 24 ),
110
+ DropdownMenu <IconLabel >(
111
+ controller: iconController,
112
+ enableFilter: true ,
113
+ requestFocusOnTap: true ,
114
+ leadingIcon: const Icon (Icons .search),
115
+ label: const Text ('Icon' ),
116
+ inputDecorationTheme: const InputDecorationTheme (
117
+ filled: true ,
118
+ contentPadding: EdgeInsets .symmetric (vertical: 5.0 ),
119
+ ),
120
+ onSelected: (IconLabel ? icon) {
121
+ setState (() {
122
+ selectedIcon = icon;
123
+ });
124
+ },
125
+ dropdownMenuEntries: IconLabel .entries,
126
+ ),
127
+ ],
128
+ ),
125
129
),
126
130
),
127
131
if (selectedColor != null && selectedIcon != null )
128
- Row (
129
- mainAxisAlignment: MainAxisAlignment .center,
130
- children: < Widget > [
131
- Text ('You selected a ${selectedColor ?.label } ${selectedIcon ?.label }' ),
132
- Padding (
133
- padding: const EdgeInsets .symmetric (horizontal: 5 ),
134
- child: Icon (selectedIcon? .icon, color: selectedColor? .color),
135
- ),
136
- ],
132
+ SingleChildScrollView (
133
+ scrollDirection: Axis .horizontal,
134
+ child: Row (
135
+ mainAxisSize: MainAxisSize .min,
136
+ mainAxisAlignment: MainAxisAlignment .center,
137
+ children: < Widget > [
138
+ Text ('You selected a ${selectedColor ?.label } ${selectedIcon ?.label }' ),
139
+ Padding (
140
+ padding: const EdgeInsets .symmetric (horizontal: 5 ),
141
+ child: Icon (selectedIcon? .icon, color: selectedColor? .color),
142
+ ),
143
+ ],
144
+ ),
137
145
)
138
146
else
139
147
const Text ('Please select a color and an icon.' ),
0 commit comments