Skip to content

Commit 3eca034

Browse files
authored
AppBar.backwardsCompatibility now default false, deprecated (flutter#86198)
1 parent 6a51e0c commit 3eca034

File tree

6 files changed

+93
-96
lines changed

6 files changed

+93
-96
lines changed

dev/integration_tests/flutter_gallery/lib/demo/shrine/backdrop.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
341341
@override
342342
Widget build(BuildContext context) {
343343
final AppBar appBar = AppBar(
344-
brightness: Brightness.light,
345344
elevation: 0.0,
346345
titleSpacing: 0.0,
347346
title: _BackdropTitle(

dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class _LoginPageState extends State<LoginPage> {
2929
appBar: AppBar(
3030
elevation: 0.0,
3131
backgroundColor: Colors.white,
32-
brightness: Brightness.light,
3332
leading: IconButton(
3433
icon: const BackButtonIcon(),
3534
tooltip: MaterialLocalizations.of(context).backButtonTooltip,

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

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,17 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
233233
this.shape,
234234
this.backgroundColor,
235235
this.foregroundColor,
236+
@Deprecated(
237+
'This property is no longer used, please use systemOverlayStyle instead. '
238+
'This feature was deprecated after v2.4.0-0.0.pre.',
239+
)
236240
this.brightness,
237241
this.iconTheme,
238242
this.actionsIconTheme,
243+
@Deprecated(
244+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
245+
'This feature was deprecated after v2.4.0-0.0.pre.',
246+
)
239247
this.textTheme,
240248
this.primary = true,
241249
this.centerTitle,
@@ -245,6 +253,10 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
245253
this.bottomOpacity = 1.0,
246254
this.toolbarHeight,
247255
this.leadingWidth,
256+
@Deprecated(
257+
'This property is obsolete and is false by default. '
258+
'This feature was deprecated after v2.4.0-0.0.pre.',
259+
)
248260
this.backwardsCompatibility,
249261
this.toolbarTextStyle,
250262
this.titleTextStyle,
@@ -523,7 +535,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
523535
final Color? foregroundColor;
524536

525537
/// {@template flutter.material.appbar.brightness}
526-
/// This property is obsolete, please use [systemOverlayStyle] instead.
538+
/// This property is deprecated, please use [systemOverlayStyle] instead.
527539
///
528540
/// Determines the brightness of the [SystemUiOverlayStyle]: for
529541
/// [Brightness.dark], [SystemUiOverlayStyle.light] is used and fo
@@ -548,6 +560,10 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
548560
/// is light or dark.
549561
/// * [backwardsCompatibility], which forces AppBar to use this
550562
/// obsolete property.
563+
@Deprecated(
564+
'This property is no longer used, please use systemOverlayStyle instead. '
565+
'This feature was deprecated after v2.4.0-0.0.pre.',
566+
)
551567
final Brightness? brightness;
552568

553569
/// {@template flutter.material.appbar.iconTheme}
@@ -583,13 +599,20 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
583599
final IconThemeData? actionsIconTheme;
584600

585601
/// {@template flutter.material.appbar.textTheme}
602+
/// This property is deprecated, please use [toolbarTextStyle] and
603+
/// [titleTextStyle] instead.
604+
///
586605
/// The typographic styles to use for text in the app bar. Typically this is
587-
/// set along with [brightness] [backgroundColor], [iconTheme].
606+
/// set along with [backgroundColor], [iconTheme].
588607
///
589608
/// If this property is null, then [AppBarTheme.textTheme] of
590609
/// [ThemeData.appBarTheme] is used. If that is also null, then
591610
/// [ThemeData.primaryTextTheme] is used.
592611
/// {@endtemplate}
612+
@Deprecated(
613+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
614+
'This feature was deprecated after v2.4.0-0.0.pre.',
615+
)
593616
final TextTheme? textTheme;
594617

595618
/// {@template flutter.material.appbar.primary}
@@ -674,21 +697,25 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
674697
final double? leadingWidth;
675698

676699
/// {@template flutter.material.appbar.backwardsCompatibility}
700+
/// This property is deprecated and is false by default.
701+
///
677702
/// If true, preserves the original defaults for the [backgroundColor],
678703
/// [iconTheme], [actionsIconTheme] properties, and the original use of
679704
/// the [textTheme] and [brightness] properties.
680705
///
681706
/// If this property is null, then [AppBarTheme.backwardsCompatibility] of
682707
/// [ThemeData.appBarTheme] is used. If that is also null, the default
683-
/// value is true.
684-
///
685-
/// This is a temporary property. When setting it to false is no
686-
/// longer considered a breaking change, it will be deprecated and
687-
/// its default value will be changed to false. App developers are
688-
/// encouraged to opt into the new features by setting it to false
689-
/// and using the [foregroundColor] and [systemOverlayStyle]
690-
/// properties as needed.
708+
/// value is false.
709+
///
710+
/// This is a temporary property and it has been deprecated. App
711+
/// developers are encouraged to opt into the new features by
712+
/// leaving it default (false) and using the [foregroundColor] and
713+
/// [systemOverlayStyle] properties as needed.
691714
/// {@endtemplate}
715+
@Deprecated(
716+
'This property is obsolete and is false by default. '
717+
'This feature was deprecated after v2.4.0-0.0.pre.',
718+
)
692719
final bool? backwardsCompatibility;
693720

694721
/// {@template flutter.material.appbar.toolbarTextStyle}
@@ -729,7 +756,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
729756
/// {@template flutter.material.appbar.systemOverlayStyle}
730757
/// Specifies the style to use for the system overlays that overlap the AppBar.
731758
///
732-
/// This property is only used if [backwardsCompatibility] is set to false.
759+
/// This property is only used if [backwardsCompatibility] is false (the default).
733760
///
734761
/// If this property is null, then [AppBarTheme.systemOverlayStyle] of
735762
/// [ThemeData.appBarTheme] is used. If that is also null, an appropriate
@@ -848,7 +875,7 @@ class _AppBarState extends State<AppBar> {
848875
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
849876

850877
final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight;
851-
final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? true;
878+
final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? false;
852879

853880
final Color backgroundColor = backwardsCompatibility
854881
? widget.backgroundColor
@@ -1513,9 +1540,17 @@ class SliverAppBar extends StatefulWidget {
15131540
this.forceElevated = false,
15141541
this.backgroundColor,
15151542
this.foregroundColor,
1543+
@Deprecated(
1544+
'This property is no longer used, please use systemOverlayStyle instead. '
1545+
'This feature was deprecated after v2.4.0-0.0.pre.',
1546+
)
15161547
this.brightness,
15171548
this.iconTheme,
15181549
this.actionsIconTheme,
1550+
@Deprecated(
1551+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
1552+
'This feature was deprecated after v2.4.0-0.0.pre.',
1553+
)
15191554
this.textTheme,
15201555
this.primary = true,
15211556
this.centerTitle,
@@ -1613,6 +1648,10 @@ class SliverAppBar extends StatefulWidget {
16131648
/// {@macro flutter.material.appbar.brightness}
16141649
///
16151650
/// This property is used to configure an [AppBar].
1651+
@Deprecated(
1652+
'This property is no longer used, please use systemOverlayStyle instead. '
1653+
'This feature was deprecated after v2.4.0-0.0.pre.',
1654+
)
16161655
final Brightness? brightness;
16171656

16181657
/// {@macro flutter.material.appbar.iconTheme}
@@ -1628,6 +1667,10 @@ class SliverAppBar extends StatefulWidget {
16281667
/// {@macro flutter.material.appbar.textTheme}
16291668
///
16301669
/// This property is used to configure an [AppBar].
1670+
@Deprecated(
1671+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
1672+
'This feature was deprecated after v2.4.0-0.0.pre.',
1673+
)
16311674
final TextTheme? textTheme;
16321675

16331676
/// {@macro flutter.material.appbar.primary}

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import 'theme.dart';
2828
class AppBarTheme with Diagnosticable {
2929
/// Creates a theme that can be used for [ThemeData.appBarTheme].
3030
const AppBarTheme({
31+
@Deprecated(
32+
'This property is no longer used, please use systemOverlayStyle instead. '
33+
'This feature was deprecated after v2.4.0-0.0.pre.',
34+
)
3135
this.brightness,
3236
Color? color,
3337
Color? backgroundColor,
@@ -36,21 +40,29 @@ class AppBarTheme with Diagnosticable {
3640
this.shadowColor,
3741
this.iconTheme,
3842
this.actionsIconTheme,
43+
@Deprecated(
44+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
45+
'This feature was deprecated after v2.4.0-0.0.pre.',
46+
)
3947
this.textTheme,
4048
this.centerTitle,
4149
this.titleSpacing,
4250
this.toolbarHeight,
4351
this.toolbarTextStyle,
4452
this.titleTextStyle,
4553
this.systemOverlayStyle,
54+
@Deprecated(
55+
'This property is obsolete and is false by default. '
56+
'This feature was deprecated after v2.4.0-0.0.pre.',
57+
)
4658
this.backwardsCompatibility,
4759
}) : assert(
4860
color == null || backgroundColor == null,
4961
'The color and backgroundColor parameters mean the same thing. Only specify one.',
5062
),
5163
backgroundColor = backgroundColor ?? color;
5264

53-
/// This property is obsolete, please use [systemOverlayStyle] instead.
65+
/// This property is deprecated, please use [systemOverlayStyle] instead.
5466
///
5567
/// Overrides the default value of the obsolete [AppBar.brightness]
5668
/// property which implicitly defines [AppBar.systemOverlayStyle] in
@@ -62,8 +74,14 @@ class AppBarTheme with Diagnosticable {
6274
/// [AppBar.systemOverlayStyle] in all descendant [AppBar] widgets.
6375
/// * [AppBar.backwardsCompatibility], which forces [AppBar] to depend
6476
/// on this obsolete property.
77+
@Deprecated(
78+
'This property is no longer used, please use systemOverlayStyle instead. '
79+
'This feature was deprecated after v2.4.0-0.0.pre.',
80+
)
6581
final Brightness? brightness;
6682

83+
/// This property is deprecated, please use [backgroundColor] instead.
84+
///
6785
/// Obsolete property that overrides the default value of
6886
/// [AppBar.backgroundColor] in all descendant [AppBar] widgets.
6987
///
@@ -74,6 +92,10 @@ class AppBarTheme with Diagnosticable {
7492
/// [AppBar.backgroundColor].
7593
/// * [AppBar.backwardsCompatibility], which forces [AppBar] to depend
7694
/// on this obsolete property.
95+
@Deprecated(
96+
'This property is no longer used, please use backgroundColor instead. '
97+
'This feature was deprecated after v2.4.0-0.0.pre.',
98+
)
7799
Color? get color => backgroundColor;
78100

79101
/// Overrides the default value of [AppBar.backgroundColor] in all
@@ -124,6 +146,9 @@ class AppBarTheme with Diagnosticable {
124146
/// [AppBar.foregroundColor] in all descendant widgets.
125147
final IconThemeData? actionsIconTheme;
126148

149+
/// This property is deprecated, please use [toolbarTextStyle] and
150+
/// [titleTextStyle] instead.
151+
///
127152
/// Overrides the default value of the obsolete [AppBar.textTheme]
128153
/// property in all descendant [AppBar] widgets.
129154
///
@@ -133,6 +158,10 @@ class AppBarTheme with Diagnosticable {
133158
/// [AppBar.toolbarTextStyle in all descendant [AppBar] widgets.
134159
/// * [titleTextStyle], which overrides the default value for
135160
/// [AppBar.titleTextStyle in all descendant [AppBar] widgets.
161+
@Deprecated(
162+
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
163+
'This feature was deprecated after v2.4.0-0.0.pre.',
164+
)
136165
final TextTheme? textTheme;
137166

138167
/// Overrides the default value for [AppBar.centerTitle].
@@ -157,7 +186,8 @@ class AppBarTheme with Diagnosticable {
157186
/// Overrides the default value for the obsolete [AppBar.toolbarTextStyle]
158187
/// property in all descendant [AppBar] widgets.
159188
///
160-
/// If this property is specified, then [backwardsCompatibility] should be true.
189+
/// If this property is specified, then [backwardsCompatibility]
190+
/// should be false (the default).
161191
///
162192
/// See also:
163193
///
@@ -168,7 +198,8 @@ class AppBarTheme with Diagnosticable {
168198
/// Overrides the default value of [AppBar.titleTextStyle]
169199
/// property in all descendant [AppBar] widgets.
170200
///
171-
/// If this property is specified, then [backwardsCompatibility] should be true.
201+
/// If this property is specified, then [backwardsCompatibility]
202+
/// should be false (the default).
172203
///
173204
/// See also:
174205
///
@@ -182,6 +213,10 @@ class AppBarTheme with Diagnosticable {
182213

183214
/// Overrides the default value of [AppBar.backwardsCompatibility]
184215
/// property in all descendant [AppBar] widgets.
216+
@Deprecated(
217+
'This property is obsolete and is false by default. '
218+
'This feature was deprecated after v2.4.0-0.0.pre.',
219+
)
185220
final bool? backwardsCompatibility;
186221

187222
/// Creates a copy of this object with the given fields replaced with the

0 commit comments

Comments
 (0)