forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
DropdownMenu
Widget to Support Material 3 (#116088)
* Created ComboBox * Fixed failing tests * Reverted the menu style tests change * Addressed comments * Updated documentation and rename foregroundColor variable * Remamed ComboBox to DropdownMenu * Removed a unused import * Removed unused import Co-authored-by: Qun Cheng <[email protected]>
- Loading branch information
1 parent
1cb16a1
commit 8b86d23
Showing
9 changed files
with
2,257 additions
and
36 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
examples/api/lib/material/dropdown_menu/dropdown_menu.0.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
/// Flutter code sample for [DropdownMenu]s. The first dropdown menu has an outlined border | ||
/// which is the default configuration, and the second one has a filled input decoration. | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() => runApp(const DropdownMenuExample()); | ||
|
||
class DropdownMenuExample extends StatelessWidget { | ||
const DropdownMenuExample({super.key}); | ||
|
||
List<DropdownMenuEntry> getEntryList() { | ||
final List<DropdownMenuEntry> entries = <DropdownMenuEntry>[]; | ||
|
||
for (int index = 0; index < EntryLabel.values.length; index++) { | ||
// Disabled item 1, 2 and 6. | ||
final bool enabled = index != 1 && index != 2 && index != 6; | ||
entries.add(DropdownMenuEntry(label: EntryLabel.values[index].label, enabled: enabled)); | ||
} | ||
return entries; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final List<DropdownMenuEntry> dropdownMenuEntries = getEntryList(); | ||
|
||
return MaterialApp( | ||
theme: ThemeData( | ||
useMaterial3: true, | ||
colorSchemeSeed: Colors.green | ||
), | ||
home: Scaffold( | ||
body: SafeArea( | ||
child: Padding( | ||
padding: const EdgeInsets.only(top: 20), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
DropdownMenu( | ||
label: const Text('Label'), | ||
dropdownMenuEntries: dropdownMenuEntries, | ||
), | ||
const SizedBox(width: 20), | ||
DropdownMenu( | ||
enableFilter: true, | ||
leadingIcon: const Icon(Icons.search), | ||
label: const Text('Label'), | ||
dropdownMenuEntries: dropdownMenuEntries, | ||
inputDecorationTheme: const InputDecorationTheme(filled: true), | ||
) | ||
], | ||
), | ||
) | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
enum EntryLabel { | ||
item0('Item 0'), | ||
item1('Item 1'), | ||
item2('Item 2'), | ||
item3('Item 3'), | ||
item4('Item 4'), | ||
item5('Item 5'), | ||
item6('Item 6'); | ||
|
||
const EntryLabel(this.label); | ||
final String label; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.