Unverified Commit 1f0b6fbd authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

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: 's avatarRenzo Olivares <roliv@google.com>
parent 8898f4f1
......@@ -872,7 +872,8 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
title: _PackageLicensePageTitle(
title,
subtitle,
theme.appBarTheme.textTheme ?? theme.primaryTextTheme,
theme.primaryTextTheme,
theme.appBarTheme.titleTextStyle,
),
),
body: Center(
......@@ -904,7 +905,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
automaticallyImplyLeading: false,
pinned: true,
backgroundColor: theme.cardColor,
title: _PackageLicensePageTitle(title, subtitle, theme.textTheme),
title: _PackageLicensePageTitle(title, subtitle, theme.textTheme, theme.textTheme.titleLarge),
),
SliverPadding(
padding: padding,
......@@ -934,21 +935,24 @@ class _PackageLicensePageTitle extends StatelessWidget {
this.title,
this.subtitle,
this.theme,
this.titleTextStyle,
);
final String title;
final String subtitle;
final TextTheme theme;
final TextStyle? titleTextStyle;
@override
Widget build(BuildContext context) {
final Color? color = Theme.of(context).appBarTheme.foregroundColor;
final TextStyle? effectiveTitleTextStyle = titleTextStyle ?? theme.titleLarge;
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(title, style: theme.titleLarge?.copyWith(color: color)),
Text(title, style: effectiveTitleTextStyle?.copyWith(color: color)),
Text(subtitle, style: theme.titleSmall?.copyWith(color: color)),
],
);
......
......@@ -201,11 +201,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
this.brightness,
this.iconTheme,
this.actionsIconTheme,
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
this.textTheme,
this.primary = true,
this.centerTitle,
this.excludeHeaderSemantics = false,
......@@ -612,23 +607,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// * [iconTheme], which defines the appearance of all of the toolbar icons.
final IconThemeData? actionsIconTheme;
/// {@template flutter.material.appbar.textTheme}
/// This property is deprecated, please use [toolbarTextStyle] and
/// [titleTextStyle] instead.
///
/// The typographic styles to use for text in the app bar. Typically this is
/// set along with [backgroundColor], [iconTheme].
///
/// If this property is null, then [AppBarTheme.textTheme] of
/// [ThemeData.appBarTheme] is used. If that is also null, then
/// [ThemeData.primaryTextTheme] is used.
/// {@endtemplate}
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
final TextTheme? textTheme;
/// {@template flutter.material.appbar.primary}
/// Whether this app bar is being displayed at the top of the screen.
///
......@@ -715,7 +693,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
///
/// If true, preserves the original defaults for the [backgroundColor],
/// [iconTheme], [actionsIconTheme] properties, and the original use of
/// the [textTheme] and [brightness] properties.
/// the [brightness] property.
///
/// If this property is null, then [AppBarTheme.backwardsCompatibility] of
/// [ThemeData.appBarTheme] is used. If that is also null, the default
......@@ -968,16 +946,16 @@ class _AppBarState extends State<AppBar> {
?? overallIconTheme;
TextStyle? toolbarTextStyle = backwardsCompatibility
? widget.textTheme?.bodyMedium
?? appBarTheme.textTheme?.bodyMedium
? widget.toolbarTextStyle
?? appBarTheme.toolbarTextStyle
?? theme.primaryTextTheme.bodyMedium
: widget.toolbarTextStyle
?? appBarTheme.toolbarTextStyle
?? defaults.toolbarTextStyle?.copyWith(color: foregroundColor);
TextStyle? titleTextStyle = backwardsCompatibility
? widget.textTheme?.titleLarge
?? appBarTheme.textTheme?.titleLarge
? widget.titleTextStyle
?? appBarTheme.titleTextStyle
?? theme.primaryTextTheme.titleLarge
: widget.titleTextStyle
?? appBarTheme.titleTextStyle
......@@ -1294,7 +1272,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
required this.brightness,
required this.iconTheme,
required this.actionsIconTheme,
required this.textTheme,
required this.primary,
required this.centerTitle,
required this.excludeHeaderSemantics,
......@@ -1335,7 +1312,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final Brightness? brightness;
final IconThemeData? iconTheme;
final IconThemeData? actionsIconTheme;
final TextTheme? textTheme;
final bool primary;
final bool? centerTitle;
final bool excludeHeaderSemantics;
......@@ -1412,7 +1388,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
brightness: brightness,
iconTheme: iconTheme,
actionsIconTheme: actionsIconTheme,
textTheme: textTheme,
primary: primary,
centerTitle: centerTitle,
excludeHeaderSemantics: excludeHeaderSemantics,
......@@ -1448,7 +1423,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|| brightness != oldDelegate.brightness
|| iconTheme != oldDelegate.iconTheme
|| actionsIconTheme != oldDelegate.actionsIconTheme
|| textTheme != oldDelegate.textTheme
|| primary != oldDelegate.primary
|| centerTitle != oldDelegate.centerTitle
|| titleSpacing != oldDelegate.titleSpacing
......@@ -1588,11 +1562,6 @@ class SliverAppBar extends StatefulWidget {
this.brightness,
this.iconTheme,
this.actionsIconTheme,
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
this.textTheme,
this.primary = true,
this.centerTitle,
this.excludeHeaderSemantics = false,
......@@ -1915,15 +1884,6 @@ class SliverAppBar extends StatefulWidget {
/// This property is used to configure an [AppBar].
final IconThemeData? actionsIconTheme;
/// {@macro flutter.material.appbar.textTheme}
///
/// This property is used to configure an [AppBar].
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
final TextTheme? textTheme;
/// {@macro flutter.material.appbar.primary}
///
/// This property is used to configure an [AppBar].
......@@ -2192,7 +2152,6 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
brightness: widget.brightness,
iconTheme: widget.iconTheme,
actionsIconTheme: widget.actionsIconTheme,
textTheme: widget.textTheme,
primary: widget.primary,
centerTitle: widget.centerTitle,
excludeHeaderSemantics: widget.excludeHeaderSemantics,
......
......@@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'text_theme.dart';
import 'theme.dart';
/// Overrides the default values of visual properties for descendant
......@@ -43,11 +42,6 @@ class AppBarTheme with Diagnosticable {
this.shape,
this.iconTheme,
this.actionsIconTheme,
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
this.textTheme,
this.centerTitle,
this.titleSpacing,
this.toolbarHeight,
......@@ -161,24 +155,6 @@ class AppBarTheme with Diagnosticable {
/// [AppBar.foregroundColor] in all descendant [AppBar] widgets.
final IconThemeData? actionsIconTheme;
/// This property is deprecated, please use [toolbarTextStyle] and
/// [titleTextStyle] instead.
///
/// Overrides the default value of the obsolete [AppBar.textTheme]
/// property in all descendant [AppBar] widgets.
///
/// See also:
///
/// * [toolbarTextStyle], which overrides the default value of
/// [AppBar.toolbarTextStyle in all descendant [AppBar] widgets.
/// * [titleTextStyle], which overrides the default value of
/// [AppBar.titleTextStyle in all descendant [AppBar] widgets.
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
final TextTheme? textTheme;
/// Overrides the default value of [AppBar.centerTitle]
/// property in all descendant [AppBar] widgets.
final bool? centerTitle;
......@@ -252,11 +228,6 @@ class AppBarTheme with Diagnosticable {
Color? surfaceTintColor,
ShapeBorder? shape,
IconThemeData? iconTheme,
@Deprecated(
'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
'This feature was deprecated after v2.4.0-0.0.pre.',
)
TextTheme? textTheme,
bool? centerTitle,
double? titleSpacing,
double? toolbarHeight,
......@@ -284,7 +255,6 @@ class AppBarTheme with Diagnosticable {
shape: shape ?? this.shape,
iconTheme: iconTheme ?? this.iconTheme,
actionsIconTheme: actionsIconTheme ?? this.actionsIconTheme,
textTheme: textTheme ?? this.textTheme,
centerTitle: centerTitle ?? this.centerTitle,
titleSpacing: titleSpacing ?? this.titleSpacing,
toolbarHeight: toolbarHeight ?? this.toolbarHeight,
......@@ -317,7 +287,6 @@ class AppBarTheme with Diagnosticable {
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
actionsIconTheme: IconThemeData.lerp(a?.actionsIconTheme, b?.actionsIconTheme, t),
textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t),
centerTitle: t < 0.5 ? a?.centerTitle : b?.centerTitle,
titleSpacing: lerpDouble(a?.titleSpacing, b?.titleSpacing, t),
toolbarHeight: lerpDouble(a?.toolbarHeight, b?.toolbarHeight, t),
......@@ -340,7 +309,6 @@ class AppBarTheme with Diagnosticable {
shape,
iconTheme,
actionsIconTheme,
textTheme,
centerTitle,
titleSpacing,
toolbarHeight,
......@@ -369,7 +337,6 @@ class AppBarTheme with Diagnosticable {
&& other.shape == shape
&& other.iconTheme == iconTheme
&& other.actionsIconTheme == actionsIconTheme
&& other.textTheme == textTheme
&& other.centerTitle == centerTitle
&& other.titleSpacing == titleSpacing
&& other.toolbarHeight == toolbarHeight
......@@ -392,7 +359,6 @@ class AppBarTheme with Diagnosticable {
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, defaultValue: null));
properties.add(DiagnosticsProperty<IconThemeData>('actionsIconTheme', actionsIconTheme, defaultValue: null));
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('centerTitle', centerTitle, defaultValue: null));
properties.add(DiagnosticsProperty<double>('titleSpacing', titleSpacing, defaultValue: null));
properties.add(DiagnosticsProperty<double>('toolbarHeight', toolbarHeight, defaultValue: null));
......
......@@ -234,7 +234,8 @@ abstract class SearchDelegate<T> {
brightness: colorScheme.brightness,
backgroundColor: colorScheme.brightness == Brightness.dark ? Colors.grey[900] : Colors.white,
iconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey),
textTheme: theme.textTheme,
titleTextStyle: theme.textTheme.titleLarge,
toolbarTextStyle: theme.textTheme.bodyMedium,
),
inputDecorationTheme: searchFieldDecorationTheme ??
InputDecorationTheme(
......
......@@ -332,10 +332,6 @@ void main() {
fontSize: 20,
color: Colors.indigo,
);
const TextStyle subtitleTextStyle = TextStyle(
fontSize: 15,
color: Colors.indigo,
);
await tester.pumpWidget(
MaterialApp(
......@@ -352,10 +348,7 @@ void main() {
),
),
appBarTheme: const AppBarTheme(
textTheme: TextTheme(
titleLarge: titleTextStyle,
titleSmall: subtitleTextStyle,
),
titleTextStyle: titleTextStyle,
foregroundColor: Colors.indigo,
),
),
......@@ -376,8 +369,6 @@ void main() {
// Check for titles style.
final Text title = tester.widget(find.text('AAA'));
expect(title.style, titleTextStyle);
final Text subtitle = tester.widget(find.text('1 license.'));
expect(subtitle.style, subtitleTextStyle);
});
testWidgets('LicensePage respects the notch', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment