Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 1f0b6fb

Browse files
Renzo-OlivaresRenzo Olivares
and
Renzo Olivares
authored
Remove deprecated AppBar/SliverAppBar/AppBarTheme.textTheme member (#119253)
* remove textTheme usage from AppBar SliverAppBar and AppBarTheme and migrate usages in the framework * Fix test * update _PackageLicensePageTitle to accept titleTextStyle * Fix test --------- Co-authored-by: Renzo Olivares <[email protected]>
1 parent 8898f4f commit 1f0b6fb

File tree

5 files changed

+15
-94
lines changed

5 files changed

+15
-94
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
872872
title: _PackageLicensePageTitle(
873873
title,
874874
subtitle,
875-
theme.appBarTheme.textTheme ?? theme.primaryTextTheme,
875+
theme.primaryTextTheme,
876+
theme.appBarTheme.titleTextStyle,
876877
),
877878
),
878879
body: Center(
@@ -904,7 +905,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
904905
automaticallyImplyLeading: false,
905906
pinned: true,
906907
backgroundColor: theme.cardColor,
907-
title: _PackageLicensePageTitle(title, subtitle, theme.textTheme),
908+
title: _PackageLicensePageTitle(title, subtitle, theme.textTheme, theme.textTheme.titleLarge),
908909
),
909910
SliverPadding(
910911
padding: padding,
@@ -934,21 +935,24 @@ class _PackageLicensePageTitle extends StatelessWidget {
934935
this.title,
935936
this.subtitle,
936937
this.theme,
938+
this.titleTextStyle,
937939
);
938940

939941
final String title;
940942
final String subtitle;
941943
final TextTheme theme;
944+
final TextStyle? titleTextStyle;
942945

943946
@override
944947
Widget build(BuildContext context) {
945948
final Color? color = Theme.of(context).appBarTheme.foregroundColor;
949+
final TextStyle? effectiveTitleTextStyle = titleTextStyle ?? theme.titleLarge;
946950

947951
return Column(
948952
mainAxisAlignment: MainAxisAlignment.center,
949953
crossAxisAlignment: CrossAxisAlignment.start,
950954
children: <Widget>[
951-
Text(title, style: theme.titleLarge?.copyWith(color: color)),
955+
Text(title, style: effectiveTitleTextStyle?.copyWith(color: color)),
952956
Text(subtitle, style: theme.titleSmall?.copyWith(color: color)),
953957
],
954958
);

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

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
201201
this.brightness,
202202
this.iconTheme,
203203
this.actionsIconTheme,
204-
@Deprecated(
205-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
206-
'This feature was deprecated after v2.4.0-0.0.pre.',
207-
)
208-
this.textTheme,
209204
this.primary = true,
210205
this.centerTitle,
211206
this.excludeHeaderSemantics = false,
@@ -612,23 +607,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
612607
/// * [iconTheme], which defines the appearance of all of the toolbar icons.
613608
final IconThemeData? actionsIconTheme;
614609

615-
/// {@template flutter.material.appbar.textTheme}
616-
/// This property is deprecated, please use [toolbarTextStyle] and
617-
/// [titleTextStyle] instead.
618-
///
619-
/// The typographic styles to use for text in the app bar. Typically this is
620-
/// set along with [backgroundColor], [iconTheme].
621-
///
622-
/// If this property is null, then [AppBarTheme.textTheme] of
623-
/// [ThemeData.appBarTheme] is used. If that is also null, then
624-
/// [ThemeData.primaryTextTheme] is used.
625-
/// {@endtemplate}
626-
@Deprecated(
627-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
628-
'This feature was deprecated after v2.4.0-0.0.pre.',
629-
)
630-
final TextTheme? textTheme;
631-
632610
/// {@template flutter.material.appbar.primary}
633611
/// Whether this app bar is being displayed at the top of the screen.
634612
///
@@ -715,7 +693,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
715693
///
716694
/// If true, preserves the original defaults for the [backgroundColor],
717695
/// [iconTheme], [actionsIconTheme] properties, and the original use of
718-
/// the [textTheme] and [brightness] properties.
696+
/// the [brightness] property.
719697
///
720698
/// If this property is null, then [AppBarTheme.backwardsCompatibility] of
721699
/// [ThemeData.appBarTheme] is used. If that is also null, the default
@@ -968,16 +946,16 @@ class _AppBarState extends State<AppBar> {
968946
?? overallIconTheme;
969947

970948
TextStyle? toolbarTextStyle = backwardsCompatibility
971-
? widget.textTheme?.bodyMedium
972-
?? appBarTheme.textTheme?.bodyMedium
949+
? widget.toolbarTextStyle
950+
?? appBarTheme.toolbarTextStyle
973951
?? theme.primaryTextTheme.bodyMedium
974952
: widget.toolbarTextStyle
975953
?? appBarTheme.toolbarTextStyle
976954
?? defaults.toolbarTextStyle?.copyWith(color: foregroundColor);
977955

978956
TextStyle? titleTextStyle = backwardsCompatibility
979-
? widget.textTheme?.titleLarge
980-
?? appBarTheme.textTheme?.titleLarge
957+
? widget.titleTextStyle
958+
?? appBarTheme.titleTextStyle
981959
?? theme.primaryTextTheme.titleLarge
982960
: widget.titleTextStyle
983961
?? appBarTheme.titleTextStyle
@@ -1294,7 +1272,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
12941272
required this.brightness,
12951273
required this.iconTheme,
12961274
required this.actionsIconTheme,
1297-
required this.textTheme,
12981275
required this.primary,
12991276
required this.centerTitle,
13001277
required this.excludeHeaderSemantics,
@@ -1335,7 +1312,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
13351312
final Brightness? brightness;
13361313
final IconThemeData? iconTheme;
13371314
final IconThemeData? actionsIconTheme;
1338-
final TextTheme? textTheme;
13391315
final bool primary;
13401316
final bool? centerTitle;
13411317
final bool excludeHeaderSemantics;
@@ -1412,7 +1388,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
14121388
brightness: brightness,
14131389
iconTheme: iconTheme,
14141390
actionsIconTheme: actionsIconTheme,
1415-
textTheme: textTheme,
14161391
primary: primary,
14171392
centerTitle: centerTitle,
14181393
excludeHeaderSemantics: excludeHeaderSemantics,
@@ -1448,7 +1423,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
14481423
|| brightness != oldDelegate.brightness
14491424
|| iconTheme != oldDelegate.iconTheme
14501425
|| actionsIconTheme != oldDelegate.actionsIconTheme
1451-
|| textTheme != oldDelegate.textTheme
14521426
|| primary != oldDelegate.primary
14531427
|| centerTitle != oldDelegate.centerTitle
14541428
|| titleSpacing != oldDelegate.titleSpacing
@@ -1588,11 +1562,6 @@ class SliverAppBar extends StatefulWidget {
15881562
this.brightness,
15891563
this.iconTheme,
15901564
this.actionsIconTheme,
1591-
@Deprecated(
1592-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
1593-
'This feature was deprecated after v2.4.0-0.0.pre.',
1594-
)
1595-
this.textTheme,
15961565
this.primary = true,
15971566
this.centerTitle,
15981567
this.excludeHeaderSemantics = false,
@@ -1915,15 +1884,6 @@ class SliverAppBar extends StatefulWidget {
19151884
/// This property is used to configure an [AppBar].
19161885
final IconThemeData? actionsIconTheme;
19171886

1918-
/// {@macro flutter.material.appbar.textTheme}
1919-
///
1920-
/// This property is used to configure an [AppBar].
1921-
@Deprecated(
1922-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
1923-
'This feature was deprecated after v2.4.0-0.0.pre.',
1924-
)
1925-
final TextTheme? textTheme;
1926-
19271887
/// {@macro flutter.material.appbar.primary}
19281888
///
19291889
/// This property is used to configure an [AppBar].
@@ -2192,7 +2152,6 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
21922152
brightness: widget.brightness,
21932153
iconTheme: widget.iconTheme,
21942154
actionsIconTheme: widget.actionsIconTheme,
2195-
textTheme: widget.textTheme,
21962155
primary: widget.primary,
21972156
centerTitle: widget.centerTitle,
21982157
excludeHeaderSemantics: widget.excludeHeaderSemantics,

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart';
88
import 'package:flutter/services.dart';
99
import 'package:flutter/widgets.dart';
1010

11-
import 'text_theme.dart';
1211
import 'theme.dart';
1312

1413
/// Overrides the default values of visual properties for descendant
@@ -43,11 +42,6 @@ class AppBarTheme with Diagnosticable {
4342
this.shape,
4443
this.iconTheme,
4544
this.actionsIconTheme,
46-
@Deprecated(
47-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
48-
'This feature was deprecated after v2.4.0-0.0.pre.',
49-
)
50-
this.textTheme,
5145
this.centerTitle,
5246
this.titleSpacing,
5347
this.toolbarHeight,
@@ -161,24 +155,6 @@ class AppBarTheme with Diagnosticable {
161155
/// [AppBar.foregroundColor] in all descendant [AppBar] widgets.
162156
final IconThemeData? actionsIconTheme;
163157

164-
/// This property is deprecated, please use [toolbarTextStyle] and
165-
/// [titleTextStyle] instead.
166-
///
167-
/// Overrides the default value of the obsolete [AppBar.textTheme]
168-
/// property in all descendant [AppBar] widgets.
169-
///
170-
/// See also:
171-
///
172-
/// * [toolbarTextStyle], which overrides the default value of
173-
/// [AppBar.toolbarTextStyle in all descendant [AppBar] widgets.
174-
/// * [titleTextStyle], which overrides the default value of
175-
/// [AppBar.titleTextStyle in all descendant [AppBar] widgets.
176-
@Deprecated(
177-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
178-
'This feature was deprecated after v2.4.0-0.0.pre.',
179-
)
180-
final TextTheme? textTheme;
181-
182158
/// Overrides the default value of [AppBar.centerTitle]
183159
/// property in all descendant [AppBar] widgets.
184160
final bool? centerTitle;
@@ -252,11 +228,6 @@ class AppBarTheme with Diagnosticable {
252228
Color? surfaceTintColor,
253229
ShapeBorder? shape,
254230
IconThemeData? iconTheme,
255-
@Deprecated(
256-
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
257-
'This feature was deprecated after v2.4.0-0.0.pre.',
258-
)
259-
TextTheme? textTheme,
260231
bool? centerTitle,
261232
double? titleSpacing,
262233
double? toolbarHeight,
@@ -284,7 +255,6 @@ class AppBarTheme with Diagnosticable {
284255
shape: shape ?? this.shape,
285256
iconTheme: iconTheme ?? this.iconTheme,
286257
actionsIconTheme: actionsIconTheme ?? this.actionsIconTheme,
287-
textTheme: textTheme ?? this.textTheme,
288258
centerTitle: centerTitle ?? this.centerTitle,
289259
titleSpacing: titleSpacing ?? this.titleSpacing,
290260
toolbarHeight: toolbarHeight ?? this.toolbarHeight,
@@ -317,7 +287,6 @@ class AppBarTheme with Diagnosticable {
317287
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
318288
iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
319289
actionsIconTheme: IconThemeData.lerp(a?.actionsIconTheme, b?.actionsIconTheme, t),
320-
textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t),
321290
centerTitle: t < 0.5 ? a?.centerTitle : b?.centerTitle,
322291
titleSpacing: lerpDouble(a?.titleSpacing, b?.titleSpacing, t),
323292
toolbarHeight: lerpDouble(a?.toolbarHeight, b?.toolbarHeight, t),
@@ -340,7 +309,6 @@ class AppBarTheme with Diagnosticable {
340309
shape,
341310
iconTheme,
342311
actionsIconTheme,
343-
textTheme,
344312
centerTitle,
345313
titleSpacing,
346314
toolbarHeight,
@@ -369,7 +337,6 @@ class AppBarTheme with Diagnosticable {
369337
&& other.shape == shape
370338
&& other.iconTheme == iconTheme
371339
&& other.actionsIconTheme == actionsIconTheme
372-
&& other.textTheme == textTheme
373340
&& other.centerTitle == centerTitle
374341
&& other.titleSpacing == titleSpacing
375342
&& other.toolbarHeight == toolbarHeight
@@ -392,7 +359,6 @@ class AppBarTheme with Diagnosticable {
392359
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
393360
properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, defaultValue: null));
394361
properties.add(DiagnosticsProperty<IconThemeData>('actionsIconTheme', actionsIconTheme, defaultValue: null));
395-
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme, defaultValue: null));
396362
properties.add(DiagnosticsProperty<bool>('centerTitle', centerTitle, defaultValue: null));
397363
properties.add(DiagnosticsProperty<double>('titleSpacing', titleSpacing, defaultValue: null));
398364
properties.add(DiagnosticsProperty<double>('toolbarHeight', toolbarHeight, defaultValue: null));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ abstract class SearchDelegate<T> {
234234
brightness: colorScheme.brightness,
235235
backgroundColor: colorScheme.brightness == Brightness.dark ? Colors.grey[900] : Colors.white,
236236
iconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey),
237-
textTheme: theme.textTheme,
237+
titleTextStyle: theme.textTheme.titleLarge,
238+
toolbarTextStyle: theme.textTheme.bodyMedium,
238239
),
239240
inputDecorationTheme: searchFieldDecorationTheme ??
240241
InputDecorationTheme(

packages/flutter/test/material/about_test.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,6 @@ void main() {
332332
fontSize: 20,
333333
color: Colors.indigo,
334334
);
335-
const TextStyle subtitleTextStyle = TextStyle(
336-
fontSize: 15,
337-
color: Colors.indigo,
338-
);
339335

340336
await tester.pumpWidget(
341337
MaterialApp(
@@ -352,10 +348,7 @@ void main() {
352348
),
353349
),
354350
appBarTheme: const AppBarTheme(
355-
textTheme: TextTheme(
356-
titleLarge: titleTextStyle,
357-
titleSmall: subtitleTextStyle,
358-
),
351+
titleTextStyle: titleTextStyle,
359352
foregroundColor: Colors.indigo,
360353
),
361354
),
@@ -376,8 +369,6 @@ void main() {
376369
// Check for titles style.
377370
final Text title = tester.widget(find.text('AAA'));
378371
expect(title.style, titleTextStyle);
379-
final Text subtitle = tester.widget(find.text('1 license.'));
380-
expect(subtitle.style, subtitleTextStyle);
381372
});
382373

383374
testWidgets('LicensePage respects the notch', (WidgetTester tester) async {

0 commit comments

Comments
 (0)