Skip to content

Commit 1bc7916

Browse files
authored
Update default menu text styles for Material 3 (flutter#131930)
Related flutter#131676 ## Description #### Fix default input text style for `DropdownMenu` ![dropdown_input](https://github.com/flutter/flutter/assets/48603081/301f8243-155a-4b8f-84a8-5e6b7bebb3bc) ### Fix default text style for `MenuAnchor`'s menu items (which `DropdownMenu` uses for menu items) ![dropdown_item](https://github.com/flutter/flutter/assets/48603081/6b5be81a-72fc-4705-a577-074c7a4cad8f) ### Default `DropdownMenu` Input text style ![Screenshot 2023-08-04 at 16 48 28](https://github.com/flutter/flutter/assets/48603081/bcd9da98-e74d-491e-ae64-6268ae0b3893) ### Default `DropdownMenu` menu item text style ![Screenshot 2023-08-04 at 16 50 19](https://github.com/flutter/flutter/assets/48603081/9592ca43-2854-45b5-8648-203ab65d9745) ### Default `MenuAnchor` menu item text style ![Screenshot 2023-08-04 at 14 34 28](https://github.com/flutter/flutter/assets/48603081/e87e1073-05f8-4dc7-a435-d864e9cce6ab) ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; /// Flutter code sample for [DropdownMenu]s. The first dropdown menu has an outlined border. void main() => runApp(const DropdownMenuExample()); class DropdownMenuExample extends StatefulWidget { const DropdownMenuExample({super.key}); @OverRide State<DropdownMenuExample> createState() => _DropdownMenuExampleState(); } class _DropdownMenuExampleState extends State<DropdownMenuExample> { final TextEditingController colorController = TextEditingController(); final TextEditingController iconController = TextEditingController(); ColorLabel? selectedColor; IconLabel? selectedIcon; @OverRide Widget build(BuildContext context) { final List<DropdownMenuEntry<ColorLabel>> colorEntries = <DropdownMenuEntry<ColorLabel>>[]; for (final ColorLabel color in ColorLabel.values) { colorEntries.add( DropdownMenuEntry<ColorLabel>( value: color, label: color.label, enabled: color.label != 'Grey'), ); } final List<DropdownMenuEntry<IconLabel>> iconEntries = <DropdownMenuEntry<IconLabel>>[]; for (final IconLabel icon in IconLabel.values) { iconEntries .add(DropdownMenuEntry<IconLabel>(value: icon, label: icon.label)); } return MaterialApp( theme: ThemeData( useMaterial3: true, colorSchemeSeed: Colors.green, // textTheme: const TextTheme( // bodyLarge: TextStyle( // fontWeight: FontWeight.bold, // fontStyle: FontStyle.italic, // decoration: TextDecoration.underline, // ), // ), ), home: Scaffold( body: SafeArea( child: Column( children: <Widget>[ const Text('DropdownMenus'), Padding( padding: const EdgeInsets.symmetric(vertical: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ DropdownMenu<ColorLabel>( controller: colorController, label: const Text('Color'), dropdownMenuEntries: colorEntries, onSelected: (ColorLabel? color) { setState(() { selectedColor = color; }); }, ), const SizedBox(width: 20), DropdownMenu<IconLabel>( controller: iconController, enableFilter: true, leadingIcon: const Icon(Icons.search), label: const Text('Icon'), dropdownMenuEntries: iconEntries, inputDecorationTheme: const InputDecorationTheme( filled: true, contentPadding: EdgeInsets.symmetric(vertical: 5.0), ), onSelected: (IconLabel? icon) { setState(() { selectedIcon = icon; }); }, ), ], ), ), const Text('Plain TextFields'), Padding( padding: const EdgeInsets.symmetric(vertical: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SizedBox( width: 150, child: TextField( controller: TextEditingController(text: 'Blue'), decoration: const InputDecoration( suffixIcon: Icon(Icons.arrow_drop_down), labelText: 'Color', border: OutlineInputBorder(), )), ), const SizedBox(width: 20), SizedBox( width: 150, child: TextField( controller: TextEditingController(text: 'Smile'), decoration: const InputDecoration( prefixIcon: Icon(Icons.search), suffixIcon: Icon(Icons.arrow_drop_down), filled: true, labelText: 'Icon', )), ), ], ), ), if (selectedColor != null && selectedIcon != null) Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'You selected a ${selectedColor?.label} ${selectedIcon?.label}'), Padding( padding: const EdgeInsets.symmetric(horizontal: 5), child: Icon( selectedIcon?.icon, color: selectedColor?.color, ), ) ], ) else const Text('Please select a color and an icon.') ], ), ), ), ); } } enum ColorLabel { blue('Blue', Colors.blue), pink('Pink', Colors.pink), green('Green', Colors.green), yellow('Yellow', Colors.yellow), grey('Grey', Colors.grey); const ColorLabel(this.label, this.color); final String label; final Color color; } enum IconLabel { smile('Smile', Icons.sentiment_satisfied_outlined), cloud( 'Cloud', Icons.cloud_outlined, ), brush('Brush', Icons.brush_outlined), heart('Heart', Icons.favorite); const IconLabel(this.label, this.icon); final String label; final IconData icon; } ``` </details>
1 parent 469c6c3 commit 1bc7916

File tree

8 files changed

+159
-28
lines changed

8 files changed

+159
-28
lines changed

dev/tools/gen_defaults/lib/menu_template.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
6565
final BuildContext context;
6666
6767
late final ColorScheme _colors = Theme.of(context).colorScheme;
68+
late final TextTheme _textTheme = Theme.of(context).textTheme;
6869
6970
@override
7071
MaterialStateProperty<Color?>? get backgroundColor {
@@ -180,7 +181,9 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
180181
181182
@override
182183
MaterialStateProperty<TextStyle?> get textStyle {
183-
return MaterialStatePropertyAll<TextStyle?>(${textStyle('md.comp.list.list-item.label-text')});
184+
// TODO(tahatesser): This is taken from https://m3.material.io/components/menus/specs
185+
// Update this when the token is available.
186+
return MaterialStatePropertyAll<TextStyle?>(_textTheme.labelLarge);
184187
}
185188
186189
@override

examples/api/test/material/menu_anchor/menu_accelerator_label.0_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ void main() {
2727
await tester.pump();
2828

2929
expect(find.text('About', findRichText: true), findsOneWidget);
30-
expect(
31-
tester.getRect(findMenu('About')),
32-
equals(const Rect.fromLTRB(4.0, 48.0, 110.5, 208.0)),
33-
);
30+
expect(tester.getRect(findMenu('About')).left, equals(4.0));
31+
expect(tester.getRect(findMenu('About')).top, equals(48.0));
32+
expect(tester.getRect(findMenu('About')).right, closeTo(98.5, 0.1));
33+
expect(tester.getRect(findMenu('About')).bottom, equals(208.0));
34+
3435
expect(find.text('Save', findRichText: true), findsOneWidget);
3536
expect(find.text('Quit', findRichText: true), findsOneWidget);
3637
expect(find.text('Magnify', findRichText: true), findsNothing);

examples/api/test/material/menu_anchor/menu_anchor.1_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ void main() {
2121

2222
await tester.tapAt(const Offset(100, 200), buttons: kSecondaryButton);
2323
await tester.pumpAndSettle();
24-
expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(100.0, 200.0, 433.0, 360.0)));
24+
expect(tester.getRect(findMenu()).left, equals(100.0));
25+
expect(tester.getRect(findMenu()).top, equals(200.0));
26+
expect(tester.getRect(findMenu()).right, closeTo(389.8, 0.1));
27+
expect(tester.getRect(findMenu()).bottom, equals(360.0));
2528

2629
// Make sure tapping in a different place causes the menu to move.
2730
await tester.tapAt(const Offset(200, 100), buttons: kSecondaryButton);
2831
await tester.pump();
2932

30-
expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(200.0, 100.0, 533.0, 260.0)));
33+
expect(tester.getRect(findMenu()).left, equals(200.0));
34+
expect(tester.getRect(findMenu()).top, equals(100.0));
35+
expect(tester.getRect(findMenu()).right, closeTo(489.8, 0.1));
36+
expect(tester.getRect(findMenu()).bottom, equals(260.0));
3137

3238
expect(find.text(example.MenuEntry.about.label), findsOneWidget);
3339
expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget);

packages/flutter/lib/src/material/dropdown_menu.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class DropdownMenu<T> extends StatefulWidget {
229229

230230
/// The text style for the [TextField] of the [DropdownMenu];
231231
///
232-
/// Defaults to the overall theme's [TextTheme.labelLarge]
232+
/// Defaults to the overall theme's [TextTheme.bodyLarge]
233233
/// if the dropdown menu theme's value is null.
234234
final TextStyle? textStyle;
235235

@@ -916,7 +916,7 @@ class _DropdownMenuDefaultsM3 extends DropdownMenuThemeData {
916916
late final ThemeData _theme = Theme.of(context);
917917

918918
@override
919-
TextStyle? get textStyle => _theme.textTheme.labelLarge;
919+
TextStyle? get textStyle => _theme.textTheme.bodyLarge;
920920

921921
@override
922922
MenuStyle get menuStyle {

packages/flutter/lib/src/material/menu_anchor.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import 'menu_style.dart';
2727
import 'menu_theme.dart';
2828
import 'radio.dart';
2929
import 'text_button.dart';
30+
import 'text_theme.dart';
3031
import 'theme.dart';
3132
import 'theme_data.dart';
3233

@@ -3676,6 +3677,7 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
36763677
final BuildContext context;
36773678

36783679
late final ColorScheme _colors = Theme.of(context).colorScheme;
3680+
late final TextTheme _textTheme = Theme.of(context).textTheme;
36793681

36803682
@override
36813683
MaterialStateProperty<Color?>? get backgroundColor {
@@ -3791,7 +3793,9 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
37913793

37923794
@override
37933795
MaterialStateProperty<TextStyle?> get textStyle {
3794-
return MaterialStatePropertyAll<TextStyle?>(Theme.of(context).textTheme.bodyLarge);
3796+
// TODO(tahatesser): This is taken from https://m3.material.io/components/menus/specs
3797+
// Update this when the token is available.
3798+
return MaterialStatePropertyAll<TextStyle?>(_textTheme.labelLarge);
37953799
}
37963800

37973801
@override

packages/flutter/test/material/dropdown_menu_test.dart

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
65
import 'dart:ui';
76

87
import 'package:flutter/material.dart';
@@ -39,15 +38,19 @@ void main() {
3938
await tester.pumpWidget(buildTest(themeData, menuChildren));
4039

4140
final EditableText editableText = tester.widget(find.byType(EditableText));
42-
expect(editableText.style.color, themeData.textTheme.labelLarge!.color);
43-
expect(editableText.style.background, themeData.textTheme.labelLarge!.background);
44-
expect(editableText.style.shadows, themeData.textTheme.labelLarge!.shadows);
45-
expect(editableText.style.decoration, themeData.textTheme.labelLarge!.decoration);
46-
expect(editableText.style.locale, themeData.textTheme.labelLarge!.locale);
47-
expect(editableText.style.wordSpacing, themeData.textTheme.labelLarge!.wordSpacing);
41+
expect(editableText.style.color, themeData.textTheme.bodyLarge!.color);
42+
expect(editableText.style.background, themeData.textTheme.bodyLarge!.background);
43+
expect(editableText.style.shadows, themeData.textTheme.bodyLarge!.shadows);
44+
expect(editableText.style.decoration, themeData.textTheme.bodyLarge!.decoration);
45+
expect(editableText.style.locale, themeData.textTheme.bodyLarge!.locale);
46+
expect(editableText.style.wordSpacing, themeData.textTheme.bodyLarge!.wordSpacing);
47+
expect(editableText.style.fontSize, 16.0);
48+
expect(editableText.style.height, 1.5);
4849

4950
final TextField textField = tester.widget(find.byType(TextField));
5051
expect(textField.decoration?.border, const OutlineInputBorder());
52+
expect(textField.style?.fontSize, 16.0);
53+
expect(textField.style?.height, 1.5);
5154

5255
await tester.tap(find.widgetWithIcon(IconButton, Icons.arrow_drop_down).first);
5356
await tester.pump();
@@ -74,6 +77,8 @@ void main() {
7477
expect(material.elevation, 0.0);
7578
expect(material.shape, const RoundedRectangleBorder());
7679
expect(material.textStyle?.color, themeData.colorScheme.onSurface);
80+
expect(material.textStyle?.fontSize, 14.0);
81+
expect(material.textStyle?.height, 1.43);
7782
});
7883

7984
testWidgets('DropdownMenu can be disabled', (WidgetTester tester) async {
@@ -177,7 +182,7 @@ void main() {
177182

178183
final Finder textField = find.byType(TextField);
179184
final double anchorWidth = tester.getSize(textField).width;
180-
expect(anchorWidth, 195.0);
185+
expect(anchorWidth, closeTo(180.5, 0.1));
181186

182187
await tester.tap(find.byType(DropdownMenu<TestMenu>));
183188
await tester.pumpAndSettle();
@@ -187,7 +192,7 @@ void main() {
187192
matching: find.byType(Material),
188193
);
189194
final double menuWidth = tester.getSize(menuMaterial).width;
190-
expect(menuWidth, 195.0);
195+
expect(menuWidth, closeTo(180.5, 0.1));
191196

192197
// The text field should have same width as the menu
193198
// when the width property is not null.
@@ -391,7 +396,8 @@ void main() {
391396
matching: find.byType(Padding),
392397
).first;
393398
final Size menuViewSize = tester.getSize(menuView);
394-
expect(menuViewSize, const Size(195.0, 304.0)); // 304 = 288 + vertical padding(2 * 8)
399+
expect(menuViewSize.width, closeTo(180.6, 0.1));
400+
expect(menuViewSize.height, equals(304.0)); // 304 = 288 + vertical padding(2 * 8)
395401

396402
// Constrains the menu height.
397403
await tester.pumpWidget(Container());
@@ -407,7 +413,8 @@ void main() {
407413
).first;
408414

409415
final Size updatedMenuSize = tester.getSize(updatedMenu);
410-
expect(updatedMenuSize, const Size(195.0, 100.0));
416+
expect(updatedMenuSize.width, closeTo(180.6, 0.1));
417+
expect(updatedMenuSize.height, equals(100.0));
411418
});
412419

413420
testWidgets('The text in the menu button should be aligned with the text of '
@@ -1518,6 +1525,52 @@ void main() {
15181525
expect(find.text('Item 5').hitTestable(), findsOneWidget);
15191526
});
15201527

1528+
// This is a regression test for https://github.com/flutter/flutter/issues/131676.
1529+
testWidgets('Material3 - DropdownMenu uses correct text styles', (WidgetTester tester) async {
1530+
const TextStyle inputTextThemeStyle = TextStyle(
1531+
fontSize: 18.5,
1532+
fontStyle: FontStyle.italic,
1533+
wordSpacing: 1.2,
1534+
decoration: TextDecoration.lineThrough,
1535+
);
1536+
const TextStyle menuItemTextThemeStyle = TextStyle(
1537+
fontSize: 20.5,
1538+
fontStyle: FontStyle.italic,
1539+
wordSpacing: 2.1,
1540+
decoration: TextDecoration.underline,
1541+
);
1542+
final ThemeData themeData = ThemeData(
1543+
useMaterial3: true,
1544+
textTheme: const TextTheme(
1545+
bodyLarge: inputTextThemeStyle,
1546+
labelLarge: menuItemTextThemeStyle,
1547+
),
1548+
);
1549+
await tester.pumpWidget(buildTest(themeData, menuChildren));
1550+
1551+
// Test input text style uses the TextTheme.bodyLarge.
1552+
final EditableText editableText = tester.widget(find.byType(EditableText));
1553+
expect(editableText.style.fontSize, inputTextThemeStyle.fontSize);
1554+
expect(editableText.style.fontStyle, inputTextThemeStyle.fontStyle);
1555+
expect(editableText.style.wordSpacing, inputTextThemeStyle.wordSpacing);
1556+
expect(editableText.style.decoration, inputTextThemeStyle.decoration);
1557+
1558+
// Open the menu.
1559+
await tester.tap(find.widgetWithIcon(IconButton, Icons.arrow_drop_down).first);
1560+
await tester.pump();
1561+
1562+
final Finder buttonMaterial = find.descendant(
1563+
of: find.byType(TextButton),
1564+
matching: find.byType(Material),
1565+
).last;
1566+
1567+
// Test menu item text style uses the TextTheme.labelLarge.
1568+
final Material material = tester.widget<Material>(buttonMaterial);
1569+
expect(material.textStyle?.fontSize, menuItemTextThemeStyle.fontSize);
1570+
expect(material.textStyle?.fontStyle, menuItemTextThemeStyle.fontStyle);
1571+
expect(material.textStyle?.wordSpacing, menuItemTextThemeStyle.wordSpacing);
1572+
expect(material.textStyle?.decoration, menuItemTextThemeStyle.decoration);
1573+
});
15211574
}
15221575

15231576
enum TestMenu {

packages/flutter/test/material/menu_anchor_test.dart

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void main() {
237237
);
238238
});
239239

240-
testWidgets('menu defaults colors', (WidgetTester tester) async {
240+
testWidgets('Menu defaults', (WidgetTester tester) async {
241241
final ThemeData themeData = ThemeData();
242242
await tester.pumpWidget(
243243
MaterialApp(
@@ -278,6 +278,8 @@ void main() {
278278
expect(material.elevation, 0.0);
279279
expect(material.shape, const RoundedRectangleBorder());
280280
expect(material.textStyle?.color, themeData.colorScheme.onSurface);
281+
expect(material.textStyle?.fontSize, 14.0);
282+
expect(material.textStyle?.height, 1.43);
281283

282284
// vertical menu
283285
await tester.tap(find.text(TestMenu.mainMenu1.label));
@@ -305,6 +307,8 @@ void main() {
305307
expect(material.elevation, 0.0);
306308
expect(material.shape, const RoundedRectangleBorder());
307309
expect(material.textStyle?.color, themeData.colorScheme.onSurface);
310+
expect(material.textStyle?.fontSize, 14.0);
311+
expect(material.textStyle?.height, 1.43);
308312

309313
await tester.tap(find.text(TestMenu.mainMenu0.label));
310314
await tester.pump();
@@ -315,7 +319,7 @@ void main() {
315319
expect(iconRichText.text.style?.color, themeData.colorScheme.onSurfaceVariant);
316320
});
317321

318-
testWidgets('menu defaults - disabled', (WidgetTester tester) async {
322+
testWidgets('Menu defaults - disabled', (WidgetTester tester) async {
319323
final ThemeData themeData = ThemeData();
320324
await tester.pumpWidget(
321325
MaterialApp(
@@ -3205,6 +3209,7 @@ void main() {
32053209
style: SubmenuButton.styleFrom(fixedSize: const Size(88.0, 36.0)),
32063210
menuChildren: <Widget>[
32073211
MenuItemButton(
3212+
style: SubmenuButton.styleFrom(fixedSize: const Size(120.0, 36.0)),
32083213
child: const Text('Item 0'),
32093214
onPressed: () {},
32103215
),
@@ -3250,17 +3255,17 @@ void main() {
32503255
),
32513256
TestSemantics(
32523257
id: 6,
3253-
rect: const Rect.fromLTRB(0.0, 0.0, 123.0, 64.0),
3258+
rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 64.0),
32543259
children: <TestSemantics> [
32553260
TestSemantics(
32563261
id: 7,
3257-
rect: const Rect.fromLTRB(0.0, 0.0, 123.0, 48.0),
3262+
rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0),
32583263
flags: <SemanticsFlag> [SemanticsFlag.hasImplicitScrolling],
32593264
children: <TestSemantics> [
32603265
TestSemantics(
32613266
id: 8,
32623267
label: 'Item 0',
3263-
rect: const Rect.fromLTRB(0.0, 0.0, 123.0, 48.0),
3268+
rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0),
32643269
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
32653270
actions: <SemanticsAction>[SemanticsAction.tap],
32663271
),
@@ -3320,6 +3325,62 @@ void main() {
33203325
semantics.dispose();
33213326
});
33223327
});
3328+
3329+
// This is a regression test for https://github.com/flutter/flutter/issues/131676.
3330+
testWidgets('Material3 - Menu uses correct text styles', (WidgetTester tester) async {
3331+
const TextStyle menuTextStyle = TextStyle(
3332+
fontSize: 18.5,
3333+
fontStyle: FontStyle.italic,
3334+
wordSpacing: 1.2,
3335+
decoration: TextDecoration.lineThrough,
3336+
);
3337+
final ThemeData themeData = ThemeData(
3338+
textTheme: const TextTheme(
3339+
labelLarge: menuTextStyle,
3340+
)
3341+
);
3342+
await tester.pumpWidget(
3343+
MaterialApp(
3344+
theme: themeData,
3345+
home: Material(
3346+
child: MenuBar(
3347+
controller: controller,
3348+
children: createTestMenus(
3349+
onPressed: onPressed,
3350+
onOpen: onOpen,
3351+
onClose: onClose,
3352+
),
3353+
),
3354+
),
3355+
),
3356+
);
3357+
3358+
// Test menu button text style uses the TextTheme.labelLarge.
3359+
Finder buttonMaterial = find.descendant(
3360+
of: find.byType(TextButton),
3361+
matching: find.byType(Material),
3362+
).first;
3363+
Material material = tester.widget<Material>(buttonMaterial);
3364+
expect(material.textStyle?.fontSize, menuTextStyle.fontSize);
3365+
expect(material.textStyle?.fontStyle, menuTextStyle.fontStyle);
3366+
expect(material.textStyle?.wordSpacing, menuTextStyle.wordSpacing);
3367+
expect(material.textStyle?.decoration, menuTextStyle.decoration);
3368+
3369+
// Open the menu.
3370+
await tester.tap(find.text(TestMenu.mainMenu1.label));
3371+
await tester.pump();
3372+
3373+
// Test menu item text style uses the TextTheme.labelLarge.
3374+
buttonMaterial = find.descendant(
3375+
of: find.widgetWithText(TextButton, TestMenu.subMenu10.label),
3376+
matching: find.byType(Material),
3377+
).first;
3378+
material = tester.widget<Material>(buttonMaterial);
3379+
expect(material.textStyle?.fontSize, menuTextStyle.fontSize);
3380+
expect(material.textStyle?.fontStyle, menuTextStyle.fontStyle);
3381+
expect(material.textStyle?.wordSpacing, menuTextStyle.wordSpacing);
3382+
expect(material.textStyle?.decoration, menuTextStyle.decoration);
3383+
});
33233384
}
33243385

33253386
List<Widget> createTestMenus({

packages/flutter/test/material/menu_style_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/foundation.dart';
56
import 'package:flutter/material.dart';
67
import 'package:flutter_test/flutter_test.dart';
78

@@ -81,8 +82,10 @@ void main() {
8182
expect(tester.getRect(findMenuPanels().first).size, equals(const Size(600.0, 60.0)));
8283

8384
// MenuTheme affects menus.
84-
expect(tester.getRect(findMenuPanels().at(1)), equals(const Rect.fromLTRB(104.0, 54.0, 204.0, 154.0)));
85-
expect(tester.getRect(findMenuPanels().at(1)).size, equals(const Size(100.0, 100.0)));
85+
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
86+
expect(tester.getRect(findMenuPanels().at(1)), equals(const Rect.fromLTRB(104.0, 54.0, 204.0, 154.0)));
87+
expect(tester.getRect(findMenuPanels().at(1)).size, equals(const Size(100.0, 100.0)));
88+
}
8689
});
8790

8891
testWidgets('maximumSize affects geometry', (WidgetTester tester) async {

0 commit comments

Comments
 (0)