Remove deprecated AppBar.color & AppBar.backwardsCompatibility (#120618)
This commit is contained in:
@@ -172,10 +172,7 @@ class _PreferredAppBarSize extends Size {
|
||||
class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
/// Creates a Material Design app bar.
|
||||
///
|
||||
/// The arguments [primary], [toolbarOpacity], [bottomOpacity],
|
||||
/// [backwardsCompatibility], and [automaticallyImplyLeading] must
|
||||
/// not be null. Additionally, if [elevation] is specified, it must
|
||||
/// be non-negative.
|
||||
/// If [elevation] is specified, it must be non-negative.
|
||||
///
|
||||
/// Typically used in the [Scaffold.appBar] property.
|
||||
AppBar({
|
||||
@@ -204,11 +201,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
this.bottomOpacity = 1.0,
|
||||
this.toolbarHeight,
|
||||
this.leadingWidth,
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
this.backwardsCompatibility,
|
||||
this.toolbarTextStyle,
|
||||
this.titleTextStyle,
|
||||
this.systemOverlayStyle,
|
||||
@@ -651,27 +643,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
/// {@endtemplate}
|
||||
final double? leadingWidth;
|
||||
|
||||
/// {@template flutter.material.appbar.backwardsCompatibility}
|
||||
/// This property is deprecated and is false by default.
|
||||
///
|
||||
/// If true, preserves the original defaults for the [backgroundColor],
|
||||
/// [iconTheme], [actionsIconTheme] properties.
|
||||
///
|
||||
/// If this property is null, then [AppBarTheme.backwardsCompatibility] of
|
||||
/// [ThemeData.appBarTheme] is used. If that is also null, the default
|
||||
/// value is false.
|
||||
///
|
||||
/// This is a temporary property and it has been deprecated. App
|
||||
/// developers are encouraged to opt into the new features by
|
||||
/// leaving it default (false) and using the [foregroundColor] and
|
||||
/// [systemOverlayStyle] properties as needed.
|
||||
/// {@endtemplate}
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
final bool? backwardsCompatibility;
|
||||
|
||||
/// {@template flutter.material.appbar.toolbarTextStyle}
|
||||
/// The default text style for the AppBar's [leading], and
|
||||
/// [actions] widgets, but not its [title].
|
||||
@@ -710,8 +681,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
/// {@template flutter.material.appbar.systemOverlayStyle}
|
||||
/// Specifies the style to use for the system overlays that overlap the AppBar.
|
||||
///
|
||||
/// This property is only used if [backwardsCompatibility] is false (the default).
|
||||
///
|
||||
/// If this property is null, then [AppBarTheme.systemOverlayStyle] of
|
||||
/// [ThemeData.appBarTheme] is used. If that is also null, an appropriate
|
||||
/// [SystemUiOverlayStyle] is calculated based on the [backgroundColor].
|
||||
@@ -862,18 +831,13 @@ class _AppBarState extends State<AppBar> {
|
||||
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
|
||||
|
||||
final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight;
|
||||
final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? false;
|
||||
|
||||
final Color backgroundColor = backwardsCompatibility
|
||||
? widget.backgroundColor
|
||||
?? appBarTheme.backgroundColor
|
||||
?? theme.primaryColor
|
||||
: _resolveColor(
|
||||
states,
|
||||
widget.backgroundColor,
|
||||
appBarTheme.backgroundColor,
|
||||
defaults.backgroundColor!,
|
||||
);
|
||||
final Color backgroundColor = _resolveColor(
|
||||
states,
|
||||
widget.backgroundColor,
|
||||
appBarTheme.backgroundColor,
|
||||
defaults.backgroundColor!,
|
||||
);
|
||||
|
||||
final Color foregroundColor = widget.foregroundColor
|
||||
?? appBarTheme.foregroundColor
|
||||
@@ -890,13 +854,9 @@ class _AppBarState extends State<AppBar> {
|
||||
?? elevation
|
||||
: elevation;
|
||||
|
||||
IconThemeData overallIconTheme = backwardsCompatibility
|
||||
? widget.iconTheme
|
||||
?? appBarTheme.iconTheme
|
||||
?? theme.primaryIconTheme
|
||||
: widget.iconTheme
|
||||
?? appBarTheme.iconTheme
|
||||
?? defaults.iconTheme!.copyWith(color: foregroundColor);
|
||||
IconThemeData overallIconTheme = widget.iconTheme
|
||||
?? appBarTheme.iconTheme
|
||||
?? defaults.iconTheme!.copyWith(color: foregroundColor);
|
||||
|
||||
final Color? actionForegroundColor = widget.foregroundColor
|
||||
?? appBarTheme.foregroundColor;
|
||||
@@ -907,21 +867,13 @@ class _AppBarState extends State<AppBar> {
|
||||
?? defaults.actionsIconTheme?.copyWith(color: actionForegroundColor)
|
||||
?? overallIconTheme;
|
||||
|
||||
TextStyle? toolbarTextStyle = backwardsCompatibility
|
||||
? widget.toolbarTextStyle
|
||||
?? appBarTheme.toolbarTextStyle
|
||||
?? theme.primaryTextTheme.bodyMedium
|
||||
: widget.toolbarTextStyle
|
||||
?? appBarTheme.toolbarTextStyle
|
||||
?? defaults.toolbarTextStyle?.copyWith(color: foregroundColor);
|
||||
TextStyle? toolbarTextStyle = widget.toolbarTextStyle
|
||||
?? appBarTheme.toolbarTextStyle
|
||||
?? defaults.toolbarTextStyle?.copyWith(color: foregroundColor);
|
||||
|
||||
TextStyle? titleTextStyle = backwardsCompatibility
|
||||
? widget.titleTextStyle
|
||||
?? appBarTheme.titleTextStyle
|
||||
?? theme.primaryTextTheme.titleLarge
|
||||
: widget.titleTextStyle
|
||||
?? appBarTheme.titleTextStyle
|
||||
?? defaults.titleTextStyle?.copyWith(color: foregroundColor);
|
||||
TextStyle? titleTextStyle = widget.titleTextStyle
|
||||
?? appBarTheme.titleTextStyle
|
||||
?? defaults.titleTextStyle?.copyWith(color: foregroundColor);
|
||||
|
||||
if (widget.toolbarOpacity != 1.0) {
|
||||
final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity);
|
||||
@@ -1173,19 +1125,15 @@ class _AppBarState extends State<AppBar> {
|
||||
);
|
||||
}
|
||||
|
||||
final SystemUiOverlayStyle overlayStyle = backwardsCompatibility
|
||||
? widget.systemOverlayStyle
|
||||
?? appBarTheme.systemOverlayStyle
|
||||
?? _systemOverlayStyleForBrightness(ThemeData.estimateBrightnessForColor(backgroundColor))
|
||||
: widget.systemOverlayStyle
|
||||
?? appBarTheme.systemOverlayStyle
|
||||
?? defaults.systemOverlayStyle
|
||||
?? _systemOverlayStyleForBrightness(
|
||||
ThemeData.estimateBrightnessForColor(backgroundColor),
|
||||
// Make the status bar transparent for M3 so the elevation overlay
|
||||
// color is picked up by the statusbar.
|
||||
theme.useMaterial3 ? const Color(0x00000000) : null,
|
||||
);
|
||||
final SystemUiOverlayStyle overlayStyle = widget.systemOverlayStyle
|
||||
?? appBarTheme.systemOverlayStyle
|
||||
?? defaults.systemOverlayStyle
|
||||
?? _systemOverlayStyleForBrightness(
|
||||
ThemeData.estimateBrightnessForColor(backgroundColor),
|
||||
// Make the status bar transparent for M3 so the elevation overlay
|
||||
// color is picked up by the statusbar.
|
||||
theme.useMaterial3 ? const Color(0x00000000) : null,
|
||||
);
|
||||
|
||||
return Semantics(
|
||||
container: true,
|
||||
@@ -1247,7 +1195,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
required this.shape,
|
||||
required this.toolbarHeight,
|
||||
required this.leadingWidth,
|
||||
required this.backwardsCompatibility,
|
||||
required this.toolbarTextStyle,
|
||||
required this.titleTextStyle,
|
||||
required this.systemOverlayStyle,
|
||||
@@ -1282,7 +1229,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
final ShapeBorder? shape;
|
||||
final double? toolbarHeight;
|
||||
final double? leadingWidth;
|
||||
final bool? backwardsCompatibility;
|
||||
final TextStyle? toolbarTextStyle;
|
||||
final TextStyle? titleTextStyle;
|
||||
final SystemUiOverlayStyle? systemOverlayStyle;
|
||||
@@ -1354,7 +1300,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
bottomOpacity: pinned ? 1.0 : clampDouble(visibleMainHeight / _bottomHeight, 0.0, 1.0),
|
||||
toolbarHeight: toolbarHeight,
|
||||
leadingWidth: leadingWidth,
|
||||
backwardsCompatibility: backwardsCompatibility,
|
||||
toolbarTextStyle: toolbarTextStyle,
|
||||
titleTextStyle: titleTextStyle,
|
||||
systemOverlayStyle: systemOverlayStyle,
|
||||
@@ -1393,7 +1338,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
|| forceElevated != oldDelegate.forceElevated
|
||||
|| toolbarHeight != oldDelegate.toolbarHeight
|
||||
|| leadingWidth != oldDelegate.leadingWidth
|
||||
|| backwardsCompatibility != oldDelegate.backwardsCompatibility
|
||||
|| toolbarTextStyle != oldDelegate.toolbarTextStyle
|
||||
|| titleTextStyle != oldDelegate.titleTextStyle
|
||||
|| systemOverlayStyle != oldDelegate.systemOverlayStyle
|
||||
@@ -1528,11 +1472,6 @@ class SliverAppBar extends StatefulWidget {
|
||||
this.shape,
|
||||
this.toolbarHeight = kToolbarHeight,
|
||||
this.leadingWidth,
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
this.backwardsCompatibility,
|
||||
this.toolbarTextStyle,
|
||||
this.titleTextStyle,
|
||||
this.systemOverlayStyle,
|
||||
@@ -1977,15 +1916,6 @@ class SliverAppBar extends StatefulWidget {
|
||||
/// This property is used to configure an [AppBar].
|
||||
final double? leadingWidth;
|
||||
|
||||
/// {@macro flutter.material.appbar.backwardsCompatibility}
|
||||
///
|
||||
/// This property is used to configure an [AppBar].
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
final bool? backwardsCompatibility;
|
||||
|
||||
/// {@macro flutter.material.appbar.toolbarTextStyle}
|
||||
///
|
||||
/// This property is used to configure an [AppBar].
|
||||
@@ -2108,7 +2038,6 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
|
||||
showOnScreenConfiguration: _showOnScreenConfiguration,
|
||||
toolbarHeight: widget.toolbarHeight,
|
||||
leadingWidth: widget.leadingWidth,
|
||||
backwardsCompatibility: widget.backwardsCompatibility,
|
||||
toolbarTextStyle: widget.toolbarTextStyle,
|
||||
titleTextStyle: widget.titleTextStyle,
|
||||
systemOverlayStyle: widget.systemOverlayStyle,
|
||||
|
||||
@@ -43,35 +43,12 @@ class AppBarTheme with Diagnosticable {
|
||||
this.toolbarTextStyle,
|
||||
this.titleTextStyle,
|
||||
this.systemOverlayStyle,
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
this.backwardsCompatibility,
|
||||
}) : assert(
|
||||
color == null || backgroundColor == null,
|
||||
'The color and backgroundColor parameters mean the same thing. Only specify one.',
|
||||
),
|
||||
backgroundColor = backgroundColor ?? color;
|
||||
|
||||
/// This property is deprecated, please use [backgroundColor] instead.
|
||||
///
|
||||
/// Obsolete property that overrides the default value of
|
||||
/// [AppBar.backgroundColor] in all descendant [AppBar] widgets.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [backgroundColor], which serves this same purpose
|
||||
/// as this property, but has a name that's consistent with
|
||||
/// [AppBar.backgroundColor].
|
||||
/// * [AppBar.backwardsCompatibility], which forces [AppBar] to depend
|
||||
/// on this obsolete property.
|
||||
@Deprecated(
|
||||
'This property is no longer used, please use backgroundColor instead. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
Color? get color => backgroundColor;
|
||||
|
||||
/// Overrides the default value of [AppBar.backgroundColor] in all
|
||||
/// descendant [AppBar] widgets.
|
||||
///
|
||||
@@ -154,9 +131,6 @@ class AppBarTheme with Diagnosticable {
|
||||
/// Overrides the default value of the obsolete [AppBar.toolbarTextStyle]
|
||||
/// property in all descendant [AppBar] widgets.
|
||||
///
|
||||
/// If this property is specified, then [backwardsCompatibility]
|
||||
/// should be false (the default).
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [titleTextStyle], which overrides the default of [AppBar.titleTextStyle]
|
||||
@@ -166,9 +140,6 @@ class AppBarTheme with Diagnosticable {
|
||||
/// Overrides the default value of [AppBar.titleTextStyle]
|
||||
/// property in all descendant [AppBar] widgets.
|
||||
///
|
||||
/// If this property is specified, then [backwardsCompatibility]
|
||||
/// should be false (the default).
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [toolbarTextStyle], which overrides the default of [AppBar.toolbarTextStyle]
|
||||
@@ -179,14 +150,6 @@ class AppBarTheme with Diagnosticable {
|
||||
/// property in all descendant [AppBar] widgets.
|
||||
final SystemUiOverlayStyle? systemOverlayStyle;
|
||||
|
||||
/// Overrides the default value of [AppBar.backwardsCompatibility]
|
||||
/// property in all descendant [AppBar] widgets.
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
final bool? backwardsCompatibility;
|
||||
|
||||
/// Creates a copy of this object with the given fields replaced with the
|
||||
/// new values.
|
||||
AppBarTheme copyWith({
|
||||
@@ -206,11 +169,6 @@ class AppBarTheme with Diagnosticable {
|
||||
TextStyle? toolbarTextStyle,
|
||||
TextStyle? titleTextStyle,
|
||||
SystemUiOverlayStyle? systemOverlayStyle,
|
||||
@Deprecated(
|
||||
'This property is obsolete and is false by default. '
|
||||
'This feature was deprecated after v2.4.0-0.0.pre.',
|
||||
)
|
||||
bool? backwardsCompatibility,
|
||||
}) {
|
||||
assert(
|
||||
color == null || backgroundColor == null,
|
||||
@@ -232,7 +190,6 @@ class AppBarTheme with Diagnosticable {
|
||||
toolbarTextStyle: toolbarTextStyle ?? this.toolbarTextStyle,
|
||||
titleTextStyle: titleTextStyle ?? this.titleTextStyle,
|
||||
systemOverlayStyle: systemOverlayStyle ?? this.systemOverlayStyle,
|
||||
backwardsCompatibility: backwardsCompatibility ?? this.backwardsCompatibility,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -263,7 +220,6 @@ class AppBarTheme with Diagnosticable {
|
||||
toolbarTextStyle: TextStyle.lerp(a?.toolbarTextStyle, b?.toolbarTextStyle, t),
|
||||
titleTextStyle: TextStyle.lerp(a?.titleTextStyle, b?.titleTextStyle, t),
|
||||
systemOverlayStyle: t < 0.5 ? a?.systemOverlayStyle : b?.systemOverlayStyle,
|
||||
backwardsCompatibility: t < 0.5 ? a?.backwardsCompatibility : b?.backwardsCompatibility,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -284,7 +240,6 @@ class AppBarTheme with Diagnosticable {
|
||||
toolbarTextStyle,
|
||||
titleTextStyle,
|
||||
systemOverlayStyle,
|
||||
backwardsCompatibility,
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -310,8 +265,7 @@ class AppBarTheme with Diagnosticable {
|
||||
&& other.toolbarHeight == toolbarHeight
|
||||
&& other.toolbarTextStyle == toolbarTextStyle
|
||||
&& other.titleTextStyle == titleTextStyle
|
||||
&& other.systemOverlayStyle == systemOverlayStyle
|
||||
&& other.backwardsCompatibility == backwardsCompatibility;
|
||||
&& other.systemOverlayStyle == systemOverlayStyle;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -331,6 +285,5 @@ class AppBarTheme with Diagnosticable {
|
||||
properties.add(DiagnosticsProperty<double>('toolbarHeight', toolbarHeight, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<TextStyle>('toolbarTextStyle', toolbarTextStyle, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<TextStyle>('titleTextStyle', titleTextStyle, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<bool>('backwardsCompatibility', backwardsCompatibility, defaultValue: null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,10 +504,10 @@ class SystemChrome {
|
||||
/// system UI styles. For instance, to change the system UI style on a new
|
||||
/// page, consider calling when pushing/popping a new [PageRoute].
|
||||
///
|
||||
/// However, the [AppBar] widget automatically sets the system overlay style
|
||||
/// based on its [AppBar.systemOverlayStyle], so configure that instead of calling
|
||||
/// this method directly. Likewise, do the same for [CupertinoNavigationBar]
|
||||
/// via [CupertinoNavigationBar.backgroundColor].
|
||||
/// The [AppBar] widget automatically sets the system overlay style based on
|
||||
/// its [AppBar.systemOverlayStyle], so configure that instead of calling this
|
||||
/// method directly. Likewise, do the same for [CupertinoNavigationBar] via
|
||||
/// [CupertinoNavigationBar.backgroundColor].
|
||||
///
|
||||
/// If a particular style is not supported on the platform, selecting it will
|
||||
/// have no effect.
|
||||
|
||||
@@ -2509,15 +2509,13 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Default status bar color', (WidgetTester tester) async {
|
||||
Future<void> pumpBoilerplate({required bool useMaterial3, required bool backwardsCompatibility}) async {
|
||||
Future<void> pumpBoilerplate({required bool useMaterial3}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
key: GlobalKey(),
|
||||
theme: ThemeData.light().copyWith(
|
||||
useMaterial3: useMaterial3,
|
||||
appBarTheme: AppBarTheme(
|
||||
backwardsCompatibility: backwardsCompatibility,
|
||||
),
|
||||
appBarTheme: const AppBarTheme(),
|
||||
),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -2528,14 +2526,10 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
await pumpBoilerplate(useMaterial3: false, backwardsCompatibility: false);
|
||||
await pumpBoilerplate(useMaterial3: false);
|
||||
expect(SystemChrome.latestStyle!.statusBarColor, null);
|
||||
await pumpBoilerplate(useMaterial3: false, backwardsCompatibility: true);
|
||||
expect(SystemChrome.latestStyle!.statusBarColor, null);
|
||||
await pumpBoilerplate(useMaterial3: true, backwardsCompatibility: false);
|
||||
await pumpBoilerplate(useMaterial3: true);
|
||||
expect(SystemChrome.latestStyle!.statusBarColor, Colors.transparent);
|
||||
await pumpBoilerplate(useMaterial3: true, backwardsCompatibility: true);
|
||||
expect(SystemChrome.latestStyle!.statusBarColor, null);
|
||||
});
|
||||
|
||||
testWidgets('AppBar systemOverlayStyle is use to style status bar and navigation bar', (WidgetTester tester) async {
|
||||
@@ -3376,53 +3370,6 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('AppBarTheme.backwardsCompatibility', (WidgetTester tester) async {
|
||||
const Color foregroundColor = Color(0xff00ff00);
|
||||
final Key leadingIconKey = UniqueKey();
|
||||
final Key actionIconKey = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData.light().copyWith(
|
||||
useMaterial3: false,
|
||||
appBarTheme: const AppBarTheme(
|
||||
backwardsCompatibility: false,
|
||||
),
|
||||
),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
foregroundColor: foregroundColor, // only applies if backwardsCompatibility is false
|
||||
leading: Icon(Icons.add_circle, key: leadingIconKey),
|
||||
title: const Text('title'),
|
||||
actions: <Widget>[Icon(Icons.ac_unit, key: actionIconKey), const Text('action')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final TextStyle titleTextStyle = tester.widget<DefaultTextStyle>(
|
||||
find.ancestor(of: find.text('title'), matching: find.byType(DefaultTextStyle)).first,
|
||||
).style;
|
||||
expect(titleTextStyle.color, foregroundColor);
|
||||
|
||||
final IconThemeData leadingIconTheme = tester.widget<IconTheme>(
|
||||
find.ancestor(of: find.byKey(leadingIconKey), matching: find.byType(IconTheme)).first,
|
||||
).data;
|
||||
expect(leadingIconTheme.color, foregroundColor);
|
||||
|
||||
final IconThemeData actionIconTheme = tester.widget<IconTheme>(
|
||||
find.ancestor(of: find.byKey(actionIconKey), matching: find.byType(IconTheme)).first,
|
||||
).data;
|
||||
expect(actionIconTheme.color, foregroundColor);
|
||||
|
||||
// Test icon color
|
||||
Color? leadingIconColor() => iconStyle(tester, Icons.add_circle)?.color;
|
||||
Color? actionIconColor() => iconStyle(tester, Icons.ac_unit)?.color;
|
||||
|
||||
expect(leadingIconColor(), foregroundColor);
|
||||
expect(actionIconColor(), foregroundColor);
|
||||
});
|
||||
|
||||
group('MaterialStateColor scrolledUnder', () {
|
||||
const double collapsedHeight = kToolbarHeight;
|
||||
const double expandedHeight = 200.0;
|
||||
|
||||
@@ -101,51 +101,6 @@ void main() {
|
||||
expect(tester.getSize(find.byType(AppBar)).width, 800);
|
||||
});
|
||||
|
||||
testWidgets('SliverAppBar allows AppBar to determine backwardsCompatibility', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/77016
|
||||
const AppBarTheme appBarTheme = AppBarTheme(
|
||||
backwardsCompatibility: false,
|
||||
backgroundColor: Colors.lightBlue,
|
||||
foregroundColor: Colors.black,
|
||||
);
|
||||
|
||||
Widget buildWithBackwardsCompatibility([bool? enabled]) => MaterialApp(
|
||||
theme: ThemeData(appBarTheme: appBarTheme),
|
||||
home: Scaffold(body: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
SliverAppBar(
|
||||
title: const Text('App Bar Title'),
|
||||
backwardsCompatibility: enabled,
|
||||
actions: <Widget>[
|
||||
IconButton(icon: const Icon(Icons.share), onPressed: () { }),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
||||
// Backwards compatibility enabled, AppBar should be built with true.
|
||||
await tester.pumpWidget(buildWithBackwardsCompatibility(true));
|
||||
AppBar appBar = tester.widget<AppBar>(find.byType(AppBar));
|
||||
expect(appBar.backwardsCompatibility, true);
|
||||
|
||||
// Backwards compatibility disabled, AppBar should be built with false.
|
||||
await tester.pumpWidget(buildWithBackwardsCompatibility(false));
|
||||
appBar = tester.widget<AppBar>(find.byType(AppBar));
|
||||
expect(appBar.backwardsCompatibility, false);
|
||||
|
||||
// Backwards compatibility unspecified, AppBar should be built with null.
|
||||
await tester.pumpWidget(buildWithBackwardsCompatibility());
|
||||
appBar = tester.widget<AppBar>(find.byType(AppBar));
|
||||
expect(appBar.backwardsCompatibility, null);
|
||||
|
||||
// AppBar should use the backwardsCompatibility of AppBarTheme.
|
||||
// Since backwardsCompatibility is false, the text color should match the
|
||||
// foreground color of the AppBarTheme.
|
||||
final DefaultTextStyle text = _getAppBarText(tester);
|
||||
expect(text.style.color, appBarTheme.foregroundColor);
|
||||
});
|
||||
|
||||
testWidgets('AppBar widget properties take priority over theme', (WidgetTester tester) async {
|
||||
const Brightness brightness = Brightness.dark;
|
||||
const SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.light;
|
||||
|
||||
Reference in New Issue
Block a user