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