Closed rydmike closed 1 year ago
The triaged-design
label is irrelevant if there is no team-design
label or fyi-design
label.
Restored triaged-design
label
I forgot to add triage-design
earlier.
@TahaTesser as this was not closed automatically when the fix PR https://github.com/flutter/flutter/pull/131930 was merged, I'm closing it manually now.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
Is there an existing issue for this?
Steps to reproduce
Based on Material-3 specification menus should use text style
labelLarge
(M3 14dp) for its menu items. For aTextfield
part in a drop down menu, the default forTextfield
should be used, which isbodyLarge
(M3 16dp). Currently Menus do not always use correct Material-3 defaults.See spec: https://m3.material.io/components/menus/specs#ad796ca6-3d66-4e7e-9322-c0d93bff5423
The supplied code sample can be used to show and demonstrate the used incorrect default text styles.
Expected results
Expect that Menu items in all menus in Material-3 mode to follow spec
labelLarge
(M3 14dp) andTextField
part ofDropdownMenu
to followTextField
spec, for its default text style, which isbodyLarge
(M3 16dp).Actual results
We find that Menu items in all menus in Material-3 mode do not follow Material-3 spec and that the
TextField
part of aDropdownMenu
does not follow theTextField
text style specification.Currently
PopupMenuButton
does use correct spec when usingPopupMenuItem
andCheckedPopupMenuItem
as content, but not if using it withListTiles
, it then usesbodyLarge
(M3 16dp). This is discussed here: https://github.com/flutter/flutter/pull/131609#issuecomment-1659024603All the new M3 menus, like
MenuBar
,MenuAnchor
andDropdownMenu
are usingbodyLarge
by default. Changing this default will be breaking, but they are currently not according to M3 specification, see spec https://m3.material.io/components/menus/specs#ad796ca6-3d66-4e7e-9322-c0d93bff5423The only place where new menus use
labelLarge
is theTextField
part in theDropdownMenu
where the input field useslabelLarge
, but as mentioned the menu that it opens usesbodyLarge
on its items. As do all other menu in Flutter that come fromMenuItemButton
used in e.g.MenuAnchor
andMenuBar
, this is coming from:https://github.com/flutter/flutter/blob/bd64bf5f923fa79635f2971531d9dfd717046963/packages/flutter/lib/src/material/menu_anchor.dart#L3792
The ironical part of this is that for the
TextField
part in aDropdownMenu
thelabelLarge
is also wrong, it should actually bebodyLarge
.If we look at Jetpack Compose and what a
DropdownMenu
looks like there, we can see that the input field is actuallybodyLarge
like the default in aTextField
. In it the items are also correctly using thelabelLarge
size like the M3 spec states for the items, so they are a bit smaller, but do follow the M3 spec for the items.The text input field then just follows the spec for the
TextField
, making it fit and match well when used together with a default styledTextField
, which is a very common use case.The M3 web spec is a bit vague on the correct default for the
TextField
in aDropdownMenu
, but it is reasonable to assume that Jetpack Compose gets this right since the style also matches what is expected on the input part when aDropdownMenu
is used in forms together withTextField
s.This means that Flutter has its
TextStyles
for input field and menu items in aDropdownMenu
reversed and generally that all menu item text styles are incorrect in all new menus.When using the
PopupMenuButton
we only get incorrect style if we populate it withListTile
s, otherwise with recent changes, it is now correct.First notice
The incorrect text styles where first mentioned and noted as a side topic in this issue https://github.com/flutter/flutter/issues/131350, it is here lifted out to its own issue.
Other known DropdownMenu Issues
Code sample
Code sample
```dart // MIT License // // Copyright (c) 2023 Mike Rydstrom // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; // This issue reported here: // A seed color for the M3 ColorScheme. const Color seedColor = Color(0xFF2E747D); // Example theme ThemeData theme(Brightness brightness, ThemeSettings settings) { // Make M3 ColorSchemes from a seed color. final ColorScheme colorScheme = ColorScheme.fromSeed( brightness: brightness, seedColor: seedColor, ); return ThemeData( colorScheme: colorScheme, useMaterial3: settings.useMaterial3, visualDensity: VisualDensity.standard, switchTheme: settings.customTheme ? SwitchThemeData( thumbIcon: MaterialStateProperty.resolveWithScreenshots or Video
Flutter Doctor output
Doctor output
```console flutter doctor -v [✓] Flutter (Channel master, 3.13.0-15.0.pre.16, on macOS 13.4.1 22F770820d darwin-arm64, locale en-US) • Flutter version 3.13.0-15.0.pre.16 on channel master at • Framework revision fcd5a6c478 (3 hours ago), 2023-08-01 06:06:40 -0400 • Engine revision 25b9d1088d • Dart version 3.2.0 (build 3.2.0-19.0.dev) • DevTools version 2.25.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/rydmike/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E300c • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] IntelliJ IDEA Community Edition (version 2023.1.3) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 74.0.4 • Dart plugin version 231.9161.14 [✓] VS Code (version 1.79.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.62.0 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-arm64 • macOS 13.4.1 22F770820d darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.114 [✓] Network resources • All expected network resources are available. ```