Several cherrypicks for G3 roll (#111787)
* Revert "Update MaterialBanner to support Material 3" (#111612)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
* Revert Ballistic & Clamping simulation updates (#111201)
* Revert "Update `MaterialBanner` to support Material 3" (#111288)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
* Revert "Use semantics label for backbutton and closebutton for Androi… (#111636)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
* Revert Ballistic & Clamping simulation updates (#111201)
* Revert "Update `MaterialBanner` to support Material 3" (#111288)
* Revert "Use semantics label for backbutton and closebutton for Android" (#111305)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
Co-authored-by: Xilai Zhang <xilaizhang@google.com>
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
Co-authored-by: Xilai Zhang <xilaizhang@google.com>
diff --git a/bin/internal/canvaskit.version b/bin/internal/canvaskit.version
index 56b4dbe..5b4d72b 100644
--- a/bin/internal/canvaskit.version
+++ b/bin/internal/canvaskit.version
@@ -1 +1 @@
-yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC
+8wh6J7ZXGCgo1vvCQIqkmskYQZfjhcXQG1YCKFNrzRUC
diff --git a/bin/internal/engine.version b/bin/internal/engine.version
index 22793ce..7cf26e4 100644
--- a/bin/internal/engine.version
+++ b/bin/internal/engine.version
@@ -1 +1 @@
-4096e133ef518fc950e74a2ea9b10c1656ddffa0
+6610f3f2a9fb278f4090f963599ba0d54186804f
diff --git a/bin/internal/fuchsia-mac.version b/bin/internal/fuchsia-mac.version
index 5a05596..3f1e1ad 100644
--- a/bin/internal/fuchsia-mac.version
+++ b/bin/internal/fuchsia-mac.version
@@ -1 +1 @@
-jTGAqMkpVAa0EiLIgeSBEX9byFU6h8-rje_DgDmlSEIC
+SptzPcGbOBfYL-TumC73XZ9vaDJbzuZrDBi7OubOYuUC
diff --git a/dev/tools/gen_defaults/bin/gen_defaults.dart b/dev/tools/gen_defaults/bin/gen_defaults.dart
index 659cec6..7186877 100644
--- a/dev/tools/gen_defaults/bin/gen_defaults.dart
+++ b/dev/tools/gen_defaults/bin/gen_defaults.dart
@@ -17,17 +17,16 @@
import 'dart:convert';
import 'dart:io';
-import 'package:gen_defaults/action_chip_template.dart';
import 'package:gen_defaults/app_bar_template.dart';
-import 'package:gen_defaults/banner_template.dart';
import 'package:gen_defaults/button_template.dart';
import 'package:gen_defaults/card_template.dart';
import 'package:gen_defaults/checkbox_template.dart';
+import 'package:gen_defaults/chip_action_template.dart';
+import 'package:gen_defaults/chip_filter_template.dart';
+import 'package:gen_defaults/chip_input_template.dart';
import 'package:gen_defaults/dialog_template.dart';
import 'package:gen_defaults/fab_template.dart';
-import 'package:gen_defaults/filter_chip_template.dart';
import 'package:gen_defaults/icon_button_template.dart';
-import 'package:gen_defaults/input_chip_template.dart';
import 'package:gen_defaults/input_decorator_template.dart';
import 'package:gen_defaults/navigation_bar_template.dart';
import 'package:gen_defaults/navigation_rail_template.dart';
@@ -104,7 +103,6 @@
tokens['colorsDark'] = _readTokenFile('color_dark.json');
AppBarTemplate('AppBar', '$materialLib/app_bar.dart', tokens).updateFile();
- BannerTemplate('Banner', '$materialLib/banner.dart', tokens).updateFile();
ButtonTemplate('md.comp.elevated-button', 'ElevatedButton', '$materialLib/elevated_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.filled-button', 'FilledButton', '$materialLib/filled_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.filled-tonal-button', 'FilledTonalButton', '$materialLib/filled_button.dart', tokens).updateFile();
@@ -112,10 +110,10 @@
ButtonTemplate('md.comp.text-button', 'TextButton', '$materialLib/text_button.dart', tokens).updateFile();
CardTemplate('Card', '$materialLib/card.dart', tokens).updateFile();
CheckboxTemplate('Checkbox', '$materialLib/checkbox.dart', tokens).updateFile();
- ChipActionTemplate('ActionChip', '$materialLib/action_chip.dart', tokens).updateFile();
- ChipFilterTemplate('FilterChip', '$materialLib/filter_chip.dart', tokens).updateFile();
- ChipFilterTemplate('FilterChip', '$materialLib/choice_chip.dart', tokens).updateFile();
- ChipInputTemplate('InputChip', '$materialLib/input_chip.dart', tokens).updateFile();
+ ChipActionTemplate('ActionChip', '$materialLib/chip_action.dart', tokens).updateFile();
+ ChipFilterTemplate('FilterChip', '$materialLib/chip_filter.dart', tokens).updateFile();
+ ChipFilterTemplate('FilterChip', '$materialLib/chip_choice.dart', tokens).updateFile();
+ ChipInputTemplate('InputChip', '$materialLib/chip_input.dart', tokens).updateFile();
DialogTemplate('Dialog', '$materialLib/dialog.dart', tokens).updateFile();
FABTemplate('FAB', '$materialLib/floating_action_button.dart', tokens).updateFile();
IconButtonTemplate('IconButton', '$materialLib/icon_button.dart', tokens).updateFile();
diff --git a/dev/tools/gen_defaults/lib/banner_template.dart b/dev/tools/gen_defaults/lib/banner_template.dart
deleted file mode 100644
index 123c8ec..0000000
--- a/dev/tools/gen_defaults/lib/banner_template.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.
-
-import 'template.dart';
-
-class BannerTemplate extends TokenTemplate {
- const BannerTemplate(super.blockName, super.fileName, super.tokens);
-
- @override
- String generate() => '''
-class _${blockName}DefaultsM3 extends MaterialBannerThemeData {
- const _${blockName}DefaultsM3(this.context)
- : super(elevation: ${elevation("md.comp.banner.container")});
-
- final BuildContext context;
-
- @override
- Color? get backgroundColor => ${componentColor("md.comp.banner.container")};
-
- @override
- Color? get surfaceTintColor => ${color("md.comp.banner.container.surface-tint-layer.color")};
-
- @override
- Color? get dividerColor => ${color("md.comp.banner.divider.color")};
-
- @override
- TextStyle? get contentTextStyle => ${textStyle("md.comp.banner.supporting-text")};
-}
-''';
-}
diff --git a/dev/tools/gen_defaults/lib/action_chip_template.dart b/dev/tools/gen_defaults/lib/chip_action_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/action_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_action_template.dart
diff --git a/dev/tools/gen_defaults/lib/filter_chip_template.dart b/dev/tools/gen_defaults/lib/chip_filter_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/filter_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_filter_template.dart
diff --git a/dev/tools/gen_defaults/lib/input_chip_template.dart b/dev/tools/gen_defaults/lib/chip_input_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/input_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_input_template.dart
diff --git a/packages/flutter/lib/src/material/back_button.dart b/packages/flutter/lib/src/material/back_button.dart
index 3feaba5..4d1f1c8 100644
--- a/packages/flutter/lib/src/material/back_button.dart
+++ b/packages/flutter/lib/src/material/back_button.dart
@@ -27,31 +27,22 @@
/// the current platform (as obtained from the [Theme]).
const BackButtonIcon({ super.key });
- @override
- Widget build(BuildContext context) {
- final String? semanticsLabel;
- final IconData data;
- switch (Theme.of(context).platform) {
+ /// Returns the appropriate "back" icon for the given `platform`.
+ static IconData _getIconData(TargetPlatform platform) {
+ switch (platform) {
case TargetPlatform.android:
- // Android uses semantics label to annotate the back button.
- semanticsLabel = MaterialLocalizations.of(context).backButtonTooltip;
- data = Icons.arrow_back;
- break;
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
- semanticsLabel = null;
- data = Icons.arrow_back;
- break;
+ return Icons.arrow_back;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
- data = Icons.arrow_back_ios;
- semanticsLabel = null;
- break;
+ return Icons.arrow_back_ios;
}
-
- return Icon(data, semanticLabel: semanticsLabel);
}
+
+ @override
+ Widget build(BuildContext context) => Icon(_getIconData(Theme.of(context).platform));
}
/// A Material Design back button.
@@ -158,22 +149,8 @@
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterialLocalizations(context));
- final String? semanticsLabel;
- switch (Theme.of(context).platform) {
- case TargetPlatform.android:
- // Android uses semantics label to annotate the close button.
- semanticsLabel = MaterialLocalizations.of(context).closeButtonTooltip;
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.linux:
- case TargetPlatform.windows:
- case TargetPlatform.iOS:
- case TargetPlatform.macOS:
- semanticsLabel = null;
- break;
- }
return IconButton(
- icon: Icon(Icons.close, semanticLabel: semanticsLabel),
+ icon: const Icon(Icons.close),
color: color,
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
onPressed: () {
diff --git a/packages/flutter/lib/src/material/banner.dart b/packages/flutter/lib/src/material/banner.dart
index 83849d0..6eede2d 100644
--- a/packages/flutter/lib/src/material/banner.dart
+++ b/packages/flutter/lib/src/material/banner.dart
@@ -102,15 +102,12 @@
this.elevation,
this.leading,
this.backgroundColor,
- this.surfaceTintColor,
- this.shadowColor,
- this.dividerColor,
this.padding,
this.leadingPadding,
this.forceActionsBelow = false,
this.overflowAlignment = OverflowBarAlignment.end,
this.animation,
- this.onVisible,
+ this.onVisible
}) : assert(elevation == null || elevation >= 0.0),
assert(content != null),
assert(actions != null),
@@ -156,29 +153,6 @@
/// also `null`, [ColorScheme.surface] of [ThemeData.colorScheme] is used.
final Color? backgroundColor;
- /// The color used as an overlay on [backgroundColor] to indicate elevation.
- ///
- /// If null, [MaterialBannerThemeData.surfaceTintColor] is used. If that
- /// is also null, the default value is [ColorScheme.surfaceTint].
- ///
- /// See [Material.surfaceTintColor] for more details on how this
- /// overlay is applied.
- final Color? surfaceTintColor;
-
- /// The color of the shadow below the [MaterialBanner].
- ///
- /// If this property is null, then [MaterialBannerThemeData.shadowColor] of
- /// [ThemeData.bannerTheme] is used. If that is also null, the default value
- /// is null.
- final Color? shadowColor;
-
- /// The color of the divider.
- ///
- /// If this property is null, then [MaterialBannerThemeData.dividerColor] of
- /// [ThemeData.bannerTheme] is used. If that is also null, the default value
- /// is [ColorScheme.surfaceVariant].
- final Color? dividerColor;
-
/// The amount of space by which to inset the [content].
///
/// If the [actions] are below the [content], this defaults to
@@ -299,7 +273,6 @@
final ThemeData theme = Theme.of(context);
final MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context);
- final MaterialBannerThemeData defaults = theme.useMaterial3 ? _BannerDefaultsM3(context) : _BannerDefaultsM2(context);
final bool isSingleRow = widget.actions.length == 1 && !widget.forceActionsBelow;
final EdgeInsetsGeometry padding = widget.padding ?? bannerTheme.padding ?? (isSingleRow
@@ -323,26 +296,16 @@
final double elevation = widget.elevation ?? bannerTheme.elevation ?? 0.0;
final Color backgroundColor = widget.backgroundColor
?? bannerTheme.backgroundColor
- ?? defaults.backgroundColor!;
- final Color? surfaceTintColor = widget.surfaceTintColor
- ?? bannerTheme.surfaceTintColor
- ?? defaults.surfaceTintColor;
- final Color? shadowColor = widget.shadowColor
- ?? bannerTheme.shadowColor;
- final Color? dividerColor = widget.dividerColor
- ?? bannerTheme.dividerColor
- ?? defaults.dividerColor;
+ ?? theme.colorScheme.surface;
final TextStyle? textStyle = widget.contentTextStyle
?? bannerTheme.contentTextStyle
- ?? defaults.contentTextStyle;
+ ?? theme.textTheme.bodyMedium;
Widget materialBanner = Container(
margin: EdgeInsets.only(bottom: elevation > 0 ? 10.0 : 0.0),
child: Material(
elevation: elevation,
color: backgroundColor,
- surfaceTintColor: surfaceTintColor,
- shadowColor: shadowColor,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
@@ -368,8 +331,9 @@
),
if (!isSingleRow)
buttonBar,
+
if (elevation == 0)
- Divider(height: 0, color: dividerColor),
+ const Divider(height: 0),
],
),
),
@@ -430,51 +394,3 @@
);
}
}
-
-class _BannerDefaultsM2 extends MaterialBannerThemeData {
- _BannerDefaultsM2(this.context)
- : _theme = Theme.of(context),
- super(elevation: 0.0);
-
- final BuildContext context;
- final ThemeData _theme;
-
- @override
- Color? get backgroundColor => _theme.colorScheme.surface;
-
- @override
- Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;
-
- @override
- TextStyle? get contentTextStyle => _theme.textTheme.bodyText2;
-}
-
-// BEGIN GENERATED TOKEN PROPERTIES - Banner
-
-// Do not edit by hand. The code between the "BEGIN GENERATED" and
-// "END GENERATED" comments are generated from data in the Material
-// Design token database by the script:
-// dev/tools/gen_defaults/bin/gen_defaults.dart.
-
-// Token database version: v0_101
-
-class _BannerDefaultsM3 extends MaterialBannerThemeData {
- const _BannerDefaultsM3(this.context)
- : super(elevation: 1.0);
-
- final BuildContext context;
-
- @override
- Color? get backgroundColor => Theme.of(context).colorScheme.surface;
-
- @override
- Color? get surfaceTintColor => Theme.of(context).colorScheme.surfaceTint;
-
- @override
- Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;
-
- @override
- TextStyle? get contentTextStyle => Theme.of(context).textTheme.bodyMedium;
-}
-
-// END GENERATED TOKEN PROPERTIES - Banner
diff --git a/packages/flutter/lib/src/material/banner_theme.dart b/packages/flutter/lib/src/material/banner_theme.dart
index 8b0b183..5081f88 100644
--- a/packages/flutter/lib/src/material/banner_theme.dart
+++ b/packages/flutter/lib/src/material/banner_theme.dart
@@ -35,9 +35,6 @@
/// [ThemeData.bannerTheme].
const MaterialBannerThemeData({
this.backgroundColor,
- this.surfaceTintColor,
- this.shadowColor,
- this.dividerColor,
this.contentTextStyle,
this.elevation,
this.padding,
@@ -47,15 +44,6 @@
/// The background color of a [MaterialBanner].
final Color? backgroundColor;
- /// Overrides the default value of [MaterialBanner.surfaceTintColor].
- final Color? surfaceTintColor;
-
- /// Overrides the default value of [MaterialBanner.shadowColor].
- final Color? shadowColor;
-
- /// Overrides the default value of [MaterialBanner.dividerColor].
- final Color? dividerColor;
-
/// Used to configure the [DefaultTextStyle] for the [MaterialBanner.content]
/// widget.
final TextStyle? contentTextStyle;
@@ -75,9 +63,6 @@
/// new values.
MaterialBannerThemeData copyWith({
Color? backgroundColor,
- Color? surfaceTintColor,
- Color? shadowColor,
- Color? dividerColor,
TextStyle? contentTextStyle,
double? elevation,
EdgeInsetsGeometry? padding,
@@ -85,9 +70,6 @@
}) {
return MaterialBannerThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
- surfaceTintColor: surfaceTintColor ?? this.surfaceTintColor,
- shadowColor: shadowColor ?? this.shadowColor,
- dividerColor: dividerColor ?? this.dividerColor,
contentTextStyle: contentTextStyle ?? this.contentTextStyle,
elevation: elevation ?? this.elevation,
padding: padding ?? this.padding,
@@ -104,9 +86,6 @@
assert(t != null);
return MaterialBannerThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
- surfaceTintColor: Color.lerp(a?.surfaceTintColor, b?.surfaceTintColor, t),
- shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
- dividerColor: Color.lerp(a?.dividerColor, b?.dividerColor, t),
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
elevation: lerpDouble(a?.elevation, b?.elevation, t),
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
@@ -117,9 +96,6 @@
@override
int get hashCode => Object.hash(
backgroundColor,
- surfaceTintColor,
- shadowColor,
- dividerColor,
contentTextStyle,
elevation,
padding,
@@ -135,25 +111,19 @@
return false;
}
return other is MaterialBannerThemeData
- && other.backgroundColor == backgroundColor
- && other.surfaceTintColor == surfaceTintColor
- && other.shadowColor == shadowColor
- && other.dividerColor == dividerColor
- && other.contentTextStyle == contentTextStyle
- && other.elevation == elevation
- && other.padding == padding
- && other.leadingPadding == leadingPadding;
+ && other.backgroundColor == backgroundColor
+ && other.contentTextStyle == contentTextStyle
+ && other.elevation == elevation
+ && other.padding == padding
+ && other.leadingPadding == leadingPadding;
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: null));
- properties.add(ColorProperty('surfaceTintColor', surfaceTintColor, defaultValue: null));
- properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: null));
- properties.add(ColorProperty('dividerColor', dividerColor, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('contentTextStyle', contentTextStyle, defaultValue: null));
- properties.add(DoubleProperty('elevation', elevation, defaultValue: null));
+ properties.add(DiagnosticsProperty<double>('elevation', elevation, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('leadingPadding', leadingPadding, defaultValue: null));
}
diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart
index 09d9fd1..d4ff9a9 100644
--- a/packages/flutter/test/material/back_button_test.dart
+++ b/packages/flutter/test/material/back_button_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -153,21 +152,9 @@
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
await tester.pumpAndSettle();
- final String? expectedLabel;
- switch(defaultTargetPlatform) {
- case TargetPlatform.android:
- expectedLabel = 'Back';
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.iOS:
- case TargetPlatform.linux:
- case TargetPlatform.macOS:
- case TargetPlatform.windows:
- expectedLabel = null;
- }
+
expect(tester.getSemantics(find.byType(BackButton)), matchesSemantics(
tooltip: 'Back',
- label: expectedLabel,
isButton: true,
hasEnabledState: true,
isEnabled: true,
@@ -175,51 +162,7 @@
isFocusable: true,
));
handle.dispose();
- }, variant: TargetPlatformVariant.all());
-
- testWidgets('CloseButton semantics', (WidgetTester tester) async {
- final SemanticsHandle handle = tester.ensureSemantics();
- await tester.pumpWidget(
- MaterialApp(
- home: const Material(child: Text('Home')),
- routes: <String, WidgetBuilder>{
- '/next': (BuildContext context) {
- return const Material(
- child: Center(
- child: CloseButton(),
- ),
- );
- },
- },
- ),
- );
-
- tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
-
- await tester.pumpAndSettle();
- final String? expectedLabel;
- switch(defaultTargetPlatform) {
- case TargetPlatform.android:
- expectedLabel = 'Close';
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.iOS:
- case TargetPlatform.linux:
- case TargetPlatform.macOS:
- case TargetPlatform.windows:
- expectedLabel = null;
- }
- expect(tester.getSemantics(find.byType(CloseButton)), matchesSemantics(
- tooltip: 'Close',
- label: expectedLabel,
- isButton: true,
- hasEnabledState: true,
- isEnabled: true,
- hasTapAction: true,
- isFocusable: true,
- ));
- handle.dispose();
- }, variant: TargetPlatformVariant.all());
+ });
testWidgets('CloseButton color', (WidgetTester tester) async {
await tester.pumpWidget(
diff --git a/packages/flutter/test/material/banner_theme_test.dart b/packages/flutter/test/material/banner_theme_test.dart
index db351f9..258966a 100644
--- a/packages/flutter/test/material/banner_theme_test.dart
+++ b/packages/flutter/test/material/banner_theme_test.dart
@@ -15,13 +15,7 @@
test('MaterialBannerThemeData null fields by default', () {
const MaterialBannerThemeData bannerTheme = MaterialBannerThemeData();
expect(bannerTheme.backgroundColor, null);
- expect(bannerTheme.surfaceTintColor, null);
- expect(bannerTheme.shadowColor, null);
- expect(bannerTheme.dividerColor, null);
expect(bannerTheme.contentTextStyle, null);
- expect(bannerTheme.elevation, null);
- expect(bannerTheme.padding, null);
- expect(bannerTheme.leadingPadding, null);
});
testWidgets('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
@@ -29,9 +23,9 @@
const MaterialBannerThemeData().debugFillProperties(builder);
final List<String> description = builder.properties
- .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
- .map((DiagnosticsNode node) => node.toString())
- .toList();
+ .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
+ .map((DiagnosticsNode node) => node.toString())
+ .toList();
expect(description, <String>[]);
});
@@ -39,43 +33,27 @@
testWidgets('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData(
- backgroundColor: Color(0xfffffff0),
- surfaceTintColor: Color(0xfffffff1),
- shadowColor: Color(0xfffffff2),
- dividerColor: Color(0xfffffff3),
- contentTextStyle: TextStyle(color: Color(0xfffffff4)),
- elevation: 4.0,
- padding: EdgeInsets.all(20.0),
- leadingPadding: EdgeInsets.only(left: 8.0),
+ backgroundColor: Color(0xFFFFFFFF),
+ contentTextStyle: TextStyle(color: Color(0xFFFFFFFF)),
).debugFillProperties(builder);
final List<String> description = builder.properties
- .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
- .map((DiagnosticsNode node) => node.toString())
- .toList();
+ .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
+ .map((DiagnosticsNode node) => node.toString())
+ .toList();
expect(description, <String>[
- 'backgroundColor: Color(0xfffffff0)',
- 'surfaceTintColor: Color(0xfffffff1)',
- 'shadowColor: Color(0xfffffff2)',
- 'dividerColor: Color(0xfffffff3)',
- 'contentTextStyle: TextStyle(inherit: true, color: Color(0xfffffff4))',
- 'elevation: 4.0',
- 'padding: EdgeInsets.all(20.0)',
- 'leadingPadding: EdgeInsets(8.0, 0.0, 0.0, 0.0)',
+ 'backgroundColor: Color(0xffffffff)',
+ 'contentTextStyle: TextStyle(inherit: true, color: Color(0xffffffff))',
]);
});
testWidgets('Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
const String contentText = 'Content';
-
await tester.pumpWidget(MaterialApp(
- theme: ThemeData(useMaterial3: true),
home: Scaffold(
body: MaterialBanner(
content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
actions: <Widget>[
TextButton(
child: const Text('Action'),
@@ -87,39 +65,16 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2021()
- expect(
- content.text.style,
- Typography.material2021().englishLike.bodyMedium!.merge(
- Typography.material2021().black.bodyMedium,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
+ expect(material.color, const Color(0xffffffff));
+ // Default value for ThemeData.typography is Typography.material2014()
+ expect(content.text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium));
});
testWidgets('Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
-
await tester.pumpWidget(MaterialApp(
- theme: ThemeData(useMaterial3: true),
home: Scaffold(
body: Builder(
builder: (BuildContext context) {
@@ -128,7 +83,6 @@
onTap: () {
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
actions: <Widget>[
TextButton(
child: const Text('Action'),
@@ -151,30 +105,10 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2021()
- expect(
- content.text.style,
- Typography.material2021().englishLike.bodyMedium!.merge(
- Typography.material2021().black.bodyMedium,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
+ expect(material.color, const Color(0xffffffff));
+ // Default value for ThemeData.typography is Typography.material2014()
+ expect(content.text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium));
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
@@ -197,12 +131,8 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, bannerTheme.backgroundColor);
- expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
- expect(material.shadowColor, bannerTheme.shadowColor);
- expect(material.elevation, bannerTheme.elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, bannerTheme.backgroundColor);
expect(content.text.style, bannerTheme.contentTextStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -212,8 +142,6 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 41);
expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
@@ -253,12 +181,8 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, bannerTheme.backgroundColor);
- expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
- expect(material.shadowColor, bannerTheme.shadowColor);
- expect(material.elevation, bannerTheme.elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, bannerTheme.backgroundColor);
expect(content.text.style, bannerTheme.contentTextStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -268,26 +192,18 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 41);
expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
- const Color surfaceTintColor = Colors.red;
- const Color shadowColor = Colors.orange;
const TextStyle textStyle = TextStyle(color: Colors.green);
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
-
await tester.pumpWidget(MaterialApp(
theme: ThemeData(bannerTheme: bannerTheme),
home: Scaffold(
body: MaterialBanner(
backgroundColor: backgroundColor,
- surfaceTintColor: surfaceTintColor,
- shadowColor: shadowColor,
- elevation: 6.0,
leading: const Icon(Icons.ac_unit),
contentTextStyle: textStyle,
content: const Text(contentText),
@@ -304,12 +220,8 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, backgroundColor);
- expect(material.surfaceTintColor, surfaceTintColor);
- expect(material.shadowColor, shadowColor);
- expect(material.elevation, 6.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, backgroundColor);
expect(content.text.style, textStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -319,18 +231,14 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 58);
expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
- const double elevation = 6.0;
const TextStyle textStyle = TextStyle(color: Colors.green);
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
-
await tester.pumpWidget(MaterialApp(
theme: ThemeData(bannerTheme: bannerTheme),
home: Scaffold(
@@ -341,7 +249,6 @@
onTap: () {
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
backgroundColor: backgroundColor,
- elevation: elevation,
leading: const Icon(Icons.ac_unit),
contentTextStyle: textStyle,
content: const Text(contentText),
@@ -369,10 +276,8 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, backgroundColor);
- expect(material.elevation, elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, backgroundColor);
expect(content.text.style, textStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -382,8 +287,6 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 58);
expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
@@ -446,130 +349,12 @@
final Material material = _getMaterialFromText(tester, contentText);
expect(material.color, colorScheme.surface);
});
-
- group('Material 2', () {
- // Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
- // is turned on by default, these tests can be removed.
-
- testWidgets('Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
- const String contentText = 'Content';
-
- await tester.pumpWidget(MaterialApp(
- home: Scaffold(
- body: MaterialBanner(
- content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
- actions: <Widget>[
- TextButton(
- child: const Text('Action'),
- onPressed: () { },
- ),
- ],
- ),
- ),
- ));
-
- final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, null);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
- final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2014()
- expect(
- content.text.style,
- Typography.material2014().englishLike.bodyText2!.merge(
- Typography.material2014().black.bodyText2,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
- });
-
- testWidgets('Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
- const String contentText = 'Content';
- const Key tapTarget = Key('tap-target');
-
- await tester.pumpWidget(MaterialApp(
- home: Scaffold(
- body: Builder(
- builder: (BuildContext context) {
- return GestureDetector(
- key: tapTarget,
- onTap: () {
- ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
- content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
- actions: <Widget>[
- TextButton(
- child: const Text('Action'),
- onPressed: () { },
- ),
- ],
- ));
- },
- behavior: HitTestBehavior.opaque,
- child: const SizedBox(
- height: 100.0,
- width: 100.0,
- ),
- );
- },
- ),
- ),
- ));
- await tester.tap(find.byKey(tapTarget));
- await tester.pumpAndSettle();
-
- final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, null);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
- final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2014()
- expect(
- content.text.style,
- Typography.material2014().englishLike.bodyText2!.merge(
- Typography.material2014().black.bodyText2,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
- });
- });
}
MaterialBannerThemeData _bannerTheme() {
return const MaterialBannerThemeData(
backgroundColor: Colors.orange,
- surfaceTintColor: Colors.yellow,
- shadowColor: Colors.red,
- dividerColor: Colors.green,
contentTextStyle: TextStyle(color: Colors.pink),
- elevation: 4.0,
padding: EdgeInsets.all(5),
leadingPadding: EdgeInsets.all(6),
);