Skip to content

Commit 525365d

Browse files
authored
Revert "Added AppBar.textButtonTheme (flutter#85585)" (flutter#85714)
1 parent 7a73915 commit 525365d

File tree

3 files changed

+7
-104
lines changed

3 files changed

+7
-104
lines changed

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

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import 'material_localizations.dart';
2222
import 'material_state.dart';
2323
import 'scaffold.dart';
2424
import 'tabs.dart';
25-
import 'text_button.dart';
26-
import 'text_button_theme.dart';
2725
import 'text_theme.dart';
2826
import 'theme.dart';
2927

@@ -195,7 +193,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
195193
this.iconTheme,
196194
this.actionsIconTheme,
197195
this.textTheme,
198-
this.textButtonTheme,
199196
this.primary = true,
200197
this.centerTitle,
201198
this.excludeHeaderSemantics = false,
@@ -521,8 +518,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
521518
///
522519
/// * [actionsIconTheme], which defines the appearance of icons in
523520
/// in the [actions] list.
524-
/// * [textButtonTheme], which defines the appearance of [TextButton]s
525-
/// in the tool bar.
526521
final IconThemeData? iconTheme;
527522

528523
/// {@template flutter.material.appbar.actionsIconTheme}
@@ -553,25 +548,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
553548
/// {@endtemplate}
554549
final TextTheme? textTheme;
555550

556-
/// {@template flutter.material.appbar.textButtonTheme}
557-
/// Defines the [ButtonStyle] applied to [TextButton]s that
558-
/// appear in the in the app bar's toolbar.
559-
///
560-
/// If this property is null, then a [ButtonStyle] configured with
561-
/// [foregroundColor] is used. This is useful because the default
562-
/// [ButtonStyle.foregroundColor] is [ColorScheme.primary], which
563-
/// is the same as the default value for the app bar's [backgroundColor].
564-
///
565-
/// This property is null by default.
566-
///
567-
/// See also:
568-
///
569-
/// * [actionsIconTheme], which defines the appearance of icons in
570-
/// in the [actions] list.
571-
/// * [iconTheme], which defines the appearance of all of the toolbar icons.
572-
/// {@endtemplate}
573-
final TextButtonThemeData? textButtonTheme;
574-
575551
/// {@template flutter.material.appbar.primary}
576552
/// Whether this app bar is being displayed at the top of the screen.
577553
///
@@ -853,10 +829,6 @@ class _AppBarState extends State<AppBar> {
853829
?? appBarTheme.iconTheme
854830
?? theme.iconTheme.copyWith(color: foregroundColor);
855831

856-
final TextButtonThemeData textButtonTheme = widget.textButtonTheme
857-
?? appBarTheme.textButtonTheme
858-
?? TextButtonThemeData(style: TextButton.styleFrom(primary: foregroundColor));
859-
860832
IconThemeData actionsIconTheme = widget.actionsIconTheme
861833
?? appBarTheme.actionsIconTheme
862834
?? overallIconTheme;
@@ -1001,10 +973,7 @@ class _AppBarState extends State<AppBar> {
1001973
data: overallIconTheme,
1002974
child: DefaultTextStyle(
1003975
style: toolbarTextStyle!,
1004-
child: TextButtonTheme(
1005-
data: textButtonTheme,
1006-
child: toolbar,
1007-
),
976+
child: toolbar,
1008977
),
1009978
),
1010979
),
@@ -1117,7 +1086,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
11171086
required this.iconTheme,
11181087
required this.actionsIconTheme,
11191088
required this.textTheme,
1120-
required this.textButtonTheme,
11211089
required this.primary,
11221090
required this.centerTitle,
11231091
required this.excludeHeaderSemantics,
@@ -1160,7 +1128,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
11601128
final IconThemeData? iconTheme;
11611129
final IconThemeData? actionsIconTheme;
11621130
final TextTheme? textTheme;
1163-
final TextButtonThemeData? textButtonTheme;
11641131
final bool primary;
11651132
final bool? centerTitle;
11661133
final bool excludeHeaderSemantics;
@@ -1235,7 +1202,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
12351202
iconTheme: iconTheme,
12361203
actionsIconTheme: actionsIconTheme,
12371204
textTheme: textTheme,
1238-
textButtonTheme: textButtonTheme,
12391205
primary: primary,
12401206
centerTitle: centerTitle,
12411207
excludeHeaderSemantics: excludeHeaderSemantics,
@@ -1271,7 +1237,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
12711237
|| iconTheme != oldDelegate.iconTheme
12721238
|| actionsIconTheme != oldDelegate.actionsIconTheme
12731239
|| textTheme != oldDelegate.textTheme
1274-
|| textButtonTheme != oldDelegate.textButtonTheme
12751240
|| primary != oldDelegate.primary
12761241
|| centerTitle != oldDelegate.centerTitle
12771242
|| titleSpacing != oldDelegate.titleSpacing
@@ -1508,7 +1473,6 @@ class SliverAppBar extends StatefulWidget {
15081473
this.iconTheme,
15091474
this.actionsIconTheme,
15101475
this.textTheme,
1511-
this.textButtonTheme,
15121476
this.primary = true,
15131477
this.centerTitle,
15141478
this.excludeHeaderSemantics = false,
@@ -1622,11 +1586,6 @@ class SliverAppBar extends StatefulWidget {
16221586
/// This property is used to configure an [AppBar].
16231587
final TextTheme? textTheme;
16241588

1625-
/// {@macro flutter.material.appbar.textButtonTheme}
1626-
///
1627-
/// This property is used to configure an [AppBar].
1628-
final TextButtonThemeData? textButtonTheme;
1629-
16301589
/// {@macro flutter.material.appbar.primary}
16311590
///
16321591
/// This property is used to configure an [AppBar].
@@ -1883,7 +1842,6 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
18831842
iconTheme: widget.iconTheme,
18841843
actionsIconTheme: widget.actionsIconTheme,
18851844
textTheme: widget.textTheme,
1886-
textButtonTheme: widget.textButtonTheme,
18871845
primary: widget.primary,
18881846
centerTitle: widget.centerTitle,
18891847
excludeHeaderSemantics: widget.excludeHeaderSemantics,

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

Lines changed: 0 additions & 19 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_button_theme.dart';
1211
import 'text_theme.dart';
1312
import 'theme.dart';
1413

@@ -38,7 +37,6 @@ class AppBarTheme with Diagnosticable {
3837
this.iconTheme,
3938
this.actionsIconTheme,
4039
this.textTheme,
41-
this.textButtonTheme,
4240
this.centerTitle,
4341
this.titleSpacing,
4442
this.toolbarHeight,
@@ -137,17 +135,6 @@ class AppBarTheme with Diagnosticable {
137135
/// [AppBar.titleTextStyle in all descendant [AppBar] widgets.
138136
final TextTheme? textTheme;
139137

140-
/// Overrides the default value of the [AppBar.textButtonTheme]
141-
/// property in all descendant [AppBar] widgets.
142-
///
143-
/// See also:
144-
///
145-
/// * [actionsIconTheme], which overrides the default value for
146-
/// [AppBar.actionsIconTheme] in all descendant [AppBar] widgets.
147-
/// * [foregroundColor], which overrides the default value
148-
/// [AppBar.foregroundColor] in all descendant widgets.
149-
final TextButtonThemeData? textButtonTheme;
150-
151138
/// Overrides the default value for [AppBar.centerTitle].
152139
/// property in all descendant widgets.
153140
final bool? centerTitle;
@@ -209,7 +196,6 @@ class AppBarTheme with Diagnosticable {
209196
Color? shadowColor,
210197
IconThemeData? iconTheme,
211198
TextTheme? textTheme,
212-
TextButtonThemeData? textButtonTheme,
213199
bool? centerTitle,
214200
double? titleSpacing,
215201
double? toolbarHeight,
@@ -231,7 +217,6 @@ class AppBarTheme with Diagnosticable {
231217
iconTheme: iconTheme ?? this.iconTheme,
232218
actionsIconTheme: actionsIconTheme ?? this.actionsIconTheme,
233219
textTheme: textTheme ?? this.textTheme,
234-
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
235220
centerTitle: centerTitle ?? this.centerTitle,
236221
titleSpacing: titleSpacing ?? this.titleSpacing,
237222
toolbarHeight: toolbarHeight ?? this.toolbarHeight,
@@ -263,7 +248,6 @@ class AppBarTheme with Diagnosticable {
263248
iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
264249
actionsIconTheme: IconThemeData.lerp(a?.actionsIconTheme, b?.actionsIconTheme, t),
265250
textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t),
266-
textButtonTheme: TextButtonThemeData.lerp(a?.textButtonTheme, b?.textButtonTheme, t),
267251
centerTitle: t < 0.5 ? a?.centerTitle : b?.centerTitle,
268252
titleSpacing: lerpDouble(a?.titleSpacing, b?.titleSpacing, t),
269253
toolbarHeight: lerpDouble(a?.toolbarHeight, b?.toolbarHeight, t),
@@ -285,7 +269,6 @@ class AppBarTheme with Diagnosticable {
285269
iconTheme,
286270
actionsIconTheme,
287271
textTheme,
288-
textButtonTheme,
289272
centerTitle,
290273
titleSpacing,
291274
toolbarHeight,
@@ -311,7 +294,6 @@ class AppBarTheme with Diagnosticable {
311294
&& other.iconTheme == iconTheme
312295
&& other.actionsIconTheme == actionsIconTheme
313296
&& other.textTheme == textTheme
314-
&& other.textButtonTheme == textButtonTheme
315297
&& other.centerTitle == centerTitle
316298
&& other.titleSpacing == titleSpacing
317299
&& other.toolbarHeight == toolbarHeight
@@ -332,7 +314,6 @@ class AppBarTheme with Diagnosticable {
332314
properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, defaultValue: null));
333315
properties.add(DiagnosticsProperty<IconThemeData>('actionsIconTheme', actionsIconTheme, defaultValue: null));
334316
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme, defaultValue: null));
335-
properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: null));
336317
properties.add(DiagnosticsProperty<bool>('centerTitle', centerTitle, defaultValue: null));
337318
properties.add(DiagnosticsProperty<double>('titleSpacing', titleSpacing, defaultValue: null));
338319
properties.add(DiagnosticsProperty<double>('toolbarHeight', toolbarHeight, defaultValue: null));

packages/flutter/test/material/app_bar_theme_test.dart

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,27 @@ void main() {
2020
home: Scaffold(
2121
appBar: AppBar(
2222
backwardsCompatibility: false,
23-
title: TextButton(onPressed: () { }, child: const Text('TitleButton')),
2423
actions: <Widget>[
25-
IconButton(onPressed: () { }, icon: const Icon(Icons.share)),
26-
TextButton(onPressed: () { }, child: const Text('ActionButton')),
24+
IconButton(icon: const Icon(Icons.share), onPressed: () { }),
2725
],
2826
),
2927
),
3028
),
3129
);
3230

3331
final Material widget = _getAppBarMaterial(tester);
34-
final RichText titleButtonText = _getAppBarButtonRichText(tester, 'TitleButton');
3532
final IconTheme iconTheme = _getAppBarIconTheme(tester);
3633
final IconTheme actionsIconTheme = _getAppBarActionsIconTheme(tester);
3734
final RichText actionIconText = _getAppBarIconRichText(tester);
38-
final RichText actionButtonText = _getAppBarButtonRichText(tester, 'ActionButton');
3935
final DefaultTextStyle text = _getAppBarText(tester);
4036

4137
expect(SystemChrome.latestStyle!.statusBarBrightness, SystemUiOverlayStyle.light.statusBarBrightness);
42-
expect(titleButtonText.text.style!.color, Colors.white);
4338
expect(widget.color, Colors.blue);
4439
expect(widget.elevation, 4.0);
4540
expect(widget.shadowColor, Colors.black);
4641
expect(iconTheme.data, const IconThemeData(color: Colors.white));
4742
expect(actionsIconTheme.data, const IconThemeData(color: Colors.white));
4843
expect(actionIconText.text.style!.color, Colors.white);
49-
expect(actionButtonText.text.style!.color, Colors.white);
5044
expect(text.style, Typography.material2014().englishLike.bodyText2!.merge(Typography.material2014().white.bodyText2));
5145
expect(tester.getSize(find.byType(AppBar)).height, kToolbarHeight);
5246
expect(tester.getSize(find.byType(AppBar)).width, 800);
@@ -63,8 +57,7 @@ void main() {
6357
backwardsCompatibility: false,
6458
title: const Text('App Bar Title'),
6559
actions: <Widget>[
66-
IconButton(onPressed: () { }, icon: const Icon(Icons.share)),
67-
TextButton(onPressed: () { }, child: const Text('ActionButton')),
60+
IconButton(icon: const Icon(Icons.share), onPressed: () { }),
6861
],
6962
),
7063
),
@@ -75,7 +68,6 @@ void main() {
7568
final IconTheme iconTheme = _getAppBarIconTheme(tester);
7669
final IconTheme actionsIconTheme = _getAppBarActionsIconTheme(tester);
7770
final RichText actionIconText = _getAppBarIconRichText(tester);
78-
final RichText actionButtonText = _getAppBarButtonRichText(tester, 'ActionButton');
7971
final DefaultTextStyle text = _getAppBarText(tester);
8072

8173
expect(SystemChrome.latestStyle!.statusBarBrightness, appBarTheme.brightness);
@@ -85,7 +77,6 @@ void main() {
8577
expect(iconTheme.data, appBarTheme.iconTheme);
8678
expect(actionsIconTheme.data, appBarTheme.actionsIconTheme);
8779
expect(actionIconText.text.style!.color, appBarTheme.actionsIconTheme!.color);
88-
expect(actionButtonText.text.style!.color, Colors.pink);
8980
expect(text.style, appBarTheme.toolbarTextStyle);
9081
expect(tester.getSize(find.byType(AppBar)).height, appBarTheme.toolbarHeight);
9182
expect(tester.getSize(find.byType(AppBar)).width, 800);
@@ -144,7 +135,6 @@ void main() {
144135
const Color shadowColor = Colors.red;
145136
const IconThemeData iconThemeData = IconThemeData(color: Colors.green);
146137
const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.lightBlue);
147-
const TextButtonThemeData textButtonTheme = TextButtonThemeData();
148138
const TextStyle toolbarTextStyle = TextStyle(color: Colors.pink);
149139
const TextStyle titleTextStyle = TextStyle(color: Colors.orange);
150140

@@ -161,7 +151,6 @@ void main() {
161151
shadowColor: shadowColor,
162152
iconTheme: iconThemeData,
163153
actionsIconTheme: actionsIconThemeData,
164-
textButtonTheme: textButtonTheme,
165154
toolbarTextStyle: toolbarTextStyle,
166155
titleTextStyle: titleTextStyle,
167156
actions: <Widget>[
@@ -186,7 +175,6 @@ void main() {
186175
expect(actionsIconTheme.data, actionsIconThemeData);
187176
expect(actionIconText.text.style!.color, actionsIconThemeData.color);
188177
expect(text.style, toolbarTextStyle);
189-
expect(_getAppBarTextButtonTheme(tester).data, textButtonTheme);
190178
});
191179

192180
testWidgets('AppBar icon color takes priority over everything', (WidgetTester tester) async {
@@ -548,22 +536,16 @@ AppBarTheme _appBarTheme() {
548536
const Color shadowColor = Colors.red;
549537
const IconThemeData iconThemeData = IconThemeData(color: Colors.black);
550538
const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.pink);
551-
final TextButtonThemeData textButtonThemeData = TextButtonThemeData(
552-
style: TextButton.styleFrom(
553-
primary: Colors.pink,
554-
),
555-
);
556-
return AppBarTheme(
539+
return const AppBarTheme(
557540
actionsIconTheme: actionsIconThemeData,
558541
brightness: brightness,
559542
backgroundColor: backgroundColor,
560543
elevation: elevation,
561544
shadowColor: shadowColor,
562545
iconTheme: iconThemeData,
563-
textButtonTheme: textButtonThemeData,
564546
toolbarHeight: 96,
565-
toolbarTextStyle: const TextStyle(color: Colors.yellow),
566-
titleTextStyle: const TextStyle(color: Colors.pink),
547+
toolbarTextStyle: TextStyle(color: Colors.yellow),
548+
titleTextStyle: TextStyle(color: Colors.pink),
567549
);
568550
}
569551

@@ -572,7 +554,7 @@ Material _getAppBarMaterial(WidgetTester tester) {
572554
find.descendant(
573555
of: find.byType(AppBar),
574556
matching: find.byType(Material),
575-
).first,
557+
),
576558
);
577559
}
578560

@@ -594,15 +576,6 @@ IconTheme _getAppBarActionsIconTheme(WidgetTester tester) {
594576
);
595577
}
596578

597-
TextButtonTheme _getAppBarTextButtonTheme(WidgetTester tester) {
598-
return tester.widget<TextButtonTheme>(
599-
find.descendant(
600-
of: find.byType(AppBar),
601-
matching: find.byType(TextButtonTheme),
602-
).first,
603-
);
604-
}
605-
606579
RichText _getAppBarIconRichText(WidgetTester tester) {
607580
return tester.widget<RichText>(
608581
find.descendant(
@@ -612,15 +585,6 @@ RichText _getAppBarIconRichText(WidgetTester tester) {
612585
);
613586
}
614587

615-
RichText _getAppBarButtonRichText(WidgetTester tester, String text) {
616-
return tester.widget<RichText>(
617-
find.descendant(
618-
of: find.text(text),
619-
matching: find.byType(RichText),
620-
).first,
621-
);
622-
}
623-
624588
DefaultTextStyle _getAppBarText(WidgetTester tester) {
625589
return tester.widget<DefaultTextStyle>(
626590
find.descendant(

0 commit comments

Comments
 (0)