Skip to content

Commit e692f29

Browse files
Use ButtonStyle.fixedSize in DevTools theme (#2658)
* Use ButtonStyle.fixedSize in DevTools theme
1 parent 7fe3375 commit e692f29

29 files changed

+94
-158
lines changed

packages/devtools_app/lib/src/analytics/prompt.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:flutter/gestures.dart';
66
import 'package:flutter/material.dart';
77

8-
import '../common_widgets.dart';
98
import '../theme.dart';
109
import '../utils.dart';
1110
import 'provider.dart';
@@ -114,7 +113,7 @@ class _AnalyticsPromptState extends State<AnalyticsPrompt> {
114113
return Row(
115114
crossAxisAlignment: CrossAxisAlignment.end,
116115
children: [
117-
FixedHeightElevatedButton(
116+
ElevatedButton(
118117
onPressed: () {
119118
_provider.setDontAllowAnalytics();
120119
setState(() {
@@ -127,7 +126,7 @@ class _AnalyticsPromptState extends State<AnalyticsPrompt> {
127126
const Padding(
128127
padding: EdgeInsets.only(left: defaultSpacing),
129128
),
130-
FixedHeightElevatedButton(
129+
ElevatedButton(
131130
onPressed: () {
132131
_provider.setAllowAnalytics();
133132
setState(() {

packages/devtools_app/lib/src/common_widgets.dart

Lines changed: 32 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ class IconLabelButton extends StatelessWidget {
112112
includeTextWidth: includeTextWidth,
113113
);
114114
if (elevatedButton) {
115-
return FixedHeightElevatedButton(
115+
return ElevatedButton(
116116
onPressed: onPressed,
117117
child: iconLabel,
118118
);
119119
}
120-
return FixedHeightOutlinedButton(
120+
return OutlinedButton(
121121
onPressed: onPressed,
122122
child: iconLabel,
123123
);
@@ -258,13 +258,17 @@ class SettingsOutlinedButton extends StatelessWidget {
258258

259259
@override
260260
Widget build(BuildContext context) {
261-
return FixedHeightOutlinedButton(
261+
return SizedBox(
262262
width: defaultButtonHeight, // This will result in a square button.
263-
onPressed: onPressed,
264-
tooltip: tooltip,
265-
child: const Icon(
266-
Icons.settings,
267-
size: defaultIconSize,
263+
child: DevToolsTooltip(
264+
tooltip: tooltip,
265+
child: OutlinedButton(
266+
onPressed: onPressed,
267+
child: const Icon(
268+
Icons.settings,
269+
size: defaultIconSize,
270+
),
271+
),
268272
),
269273
);
270274
}
@@ -298,7 +302,7 @@ class ExpandAllButton extends StatelessWidget {
298302

299303
@override
300304
Widget build(BuildContext context) {
301-
return FixedHeightOutlinedButton(
305+
return OutlinedButton(
302306
onPressed: onPressed,
303307
child: const Text('Expand All'),
304308
);
@@ -313,93 +317,13 @@ class CollapseAllButton extends StatelessWidget {
313317

314318
@override
315319
Widget build(BuildContext context) {
316-
return FixedHeightOutlinedButton(
320+
return OutlinedButton(
317321
onPressed: onPressed,
318322
child: const Text('Collapse All'),
319323
);
320324
}
321325
}
322326

323-
// TODO(kenz): remove use of this class once we can specify a fixed button
324-
// height in the theme. See https://github.com/flutter/flutter/issues/73741.
325-
class FixedHeightOutlinedButton extends StatelessWidget {
326-
const FixedHeightOutlinedButton({
327-
this.buttonKey,
328-
@required this.onPressed,
329-
@required this.child,
330-
this.autofocus = false,
331-
this.style,
332-
this.width,
333-
this.tooltip,
334-
});
335-
336-
final Key buttonKey;
337-
338-
final VoidCallback onPressed;
339-
340-
final Widget child;
341-
342-
final bool autofocus;
343-
344-
final ButtonStyle style;
345-
346-
final double width;
347-
348-
final String tooltip;
349-
350-
@override
351-
Widget build(BuildContext context) {
352-
final button = SizedBox(
353-
height: defaultButtonHeight,
354-
width: width,
355-
child: OutlinedButton(
356-
key: buttonKey,
357-
style: style,
358-
autofocus: autofocus,
359-
onPressed: onPressed,
360-
child: child,
361-
),
362-
);
363-
if (tooltip != null) {
364-
return Tooltip(
365-
message: tooltip,
366-
preferBelow: false,
367-
waitDuration: tooltipWait,
368-
child: button,
369-
);
370-
}
371-
return button;
372-
}
373-
}
374-
375-
// TODO(kenz): remove use of this class once we can specify a fixed button
376-
// height in the theme. See https://github.com/flutter/flutter/issues/73741.
377-
class FixedHeightElevatedButton extends StatelessWidget {
378-
const FixedHeightElevatedButton({
379-
@required this.child,
380-
@required this.onPressed,
381-
this.style,
382-
});
383-
384-
final Widget child;
385-
386-
final VoidCallback onPressed;
387-
388-
final ButtonStyle style;
389-
390-
@override
391-
Widget build(BuildContext context) {
392-
return SizedBox(
393-
height: defaultButtonHeight,
394-
child: ElevatedButton(
395-
style: style,
396-
onPressed: onPressed,
397-
child: child,
398-
),
399-
);
400-
}
401-
}
402-
403327
class RecordingInfo extends StatelessWidget {
404328
const RecordingInfo({
405329
this.instructionsKey,
@@ -573,8 +497,8 @@ class ExitOfflineButton extends StatelessWidget {
573497

574498
@override
575499
Widget build(BuildContext context) {
576-
return FixedHeightOutlinedButton(
577-
buttonKey: const Key('exit offline button'),
500+
return OutlinedButton(
501+
key: const Key('exit offline button'),
578502
onPressed: onPressed,
579503
child: const MaterialIconLabel(
580504
label: 'Exit offline mode',
@@ -841,21 +765,23 @@ class FilterButton extends StatelessWidget {
841765
@override
842766
Widget build(BuildContext context) {
843767
final theme = Theme.of(context);
844-
return FixedHeightOutlinedButton(
845-
buttonKey: key,
768+
return DevToolsTooltip(
846769
tooltip: 'Filter',
847-
onPressed: onPressed,
848-
style: TextButton.styleFrom(
849-
backgroundColor: isFilterActive
850-
? theme.colorScheme.toggleButtonBackgroundColor
851-
: Colors.transparent,
852-
),
853-
child: Icon(
854-
Icons.filter_list,
855-
size: defaultIconSize,
856-
color: isFilterActive
857-
? theme.colorScheme.toggleButtonForegroundColor
858-
: theme.colorScheme.contrastForeground,
770+
child: OutlinedButton(
771+
key: key,
772+
onPressed: onPressed,
773+
style: TextButton.styleFrom(
774+
backgroundColor: isFilterActive
775+
? theme.colorScheme.toggleButtonBackgroundColor
776+
: Colors.transparent,
777+
),
778+
child: Icon(
779+
Icons.filter_list,
780+
size: defaultIconSize,
781+
color: isFilterActive
782+
? theme.colorScheme.toggleButtonForegroundColor
783+
: theme.colorScheme.contrastForeground,
784+
),
859785
),
860786
);
861787
}

packages/devtools_app/lib/src/debugger/controls.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,20 @@ class DebuggerButton extends StatelessWidget {
232232

233233
@override
234234
Widget build(BuildContext context) {
235-
return FixedHeightOutlinedButton(
236-
autofocus: autofocus,
235+
return DevToolsTooltip(
237236
tooltip: title,
238-
style: OutlinedButton.styleFrom(
239-
side: BorderSide.none,
240-
shape: const ContinuousRectangleBorder(),
241-
),
242-
onPressed: onPressed,
243-
child: MaterialIconLabel(
244-
label: title,
245-
iconData: icon,
246-
includeTextWidth: mediumDeviceWidth,
237+
child: OutlinedButton(
238+
autofocus: autofocus,
239+
style: OutlinedButton.styleFrom(
240+
side: BorderSide.none,
241+
shape: const ContinuousRectangleBorder(),
242+
),
243+
onPressed: onPressed,
244+
child: MaterialIconLabel(
245+
label: title,
246+
iconData: icon,
247+
includeTextWidth: mediumDeviceWidth,
248+
),
247249
),
248250
);
249251
}

packages/devtools_app/lib/src/device_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class DeviceDialog extends StatelessWidget {
9696
}
9797

9898
Widget _connectToNewAppButton(BuildContext context) {
99-
return FixedHeightElevatedButton(
99+
return ElevatedButton(
100100
onPressed: () {
101101
DevToolsRouterDelegate.of(context).navigate(homePageId, {'uri': null});
102102
Navigator.of(context, rootNavigator: true).pop('dialog');

packages/devtools_app/lib/src/file_import.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class _FileImportContainerState extends State<FileImportContainer> {
153153
Row(
154154
mainAxisAlignment: MainAxisAlignment.center,
155155
children: [
156-
FixedHeightElevatedButton(
156+
ElevatedButton(
157157
onPressed: importedFile != null
158158
? () => widget.onAction(importedFile)
159159
: null,
@@ -316,7 +316,7 @@ class _DualFileImportContainerState extends State<DualFileImportContainer> {
316316
Row(
317317
mainAxisAlignment: MainAxisAlignment.center,
318318
children: [
319-
FixedHeightElevatedButton(
319+
ElevatedButton(
320320
onPressed: firstImportedFile != null && secondImportedFile != null
321321
? () => widget.onAction(
322322
firstImportedFile,

packages/devtools_app/lib/src/initializer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class _InitializerState extends State<Initializer>
152152
Text('Disconnected', style: theme.textTheme.headline3),
153153
const SizedBox(height: defaultSpacing),
154154
if (widget.allowConnectionScreenOnDisconnect)
155-
FixedHeightElevatedButton(
155+
ElevatedButton(
156156
onPressed: () {
157157
hideDisconnectedOverlay();
158158
DevToolsRouterDelegate.of(context)
@@ -165,7 +165,7 @@ class _InitializerState extends State<Initializer>
165165
style: theme.textTheme.bodyText2,
166166
),
167167
const Spacer(),
168-
FixedHeightElevatedButton(
168+
ElevatedButton(
169169
onPressed: hideDisconnectedOverlay,
170170
child: const Text('Review History'),
171171
),

packages/devtools_app/lib/src/inspector/inspector_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
229229
mainAxisSize: MainAxisSize.min,
230230
children: [
231231
Flexible(
232-
child: FixedHeightOutlinedButton(
232+
child: OutlinedButton(
233233
onPressed: enableButtons ? _onExpandClick : null,
234234
child: const Text(
235235
'Expand all',
@@ -239,7 +239,7 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
239239
),
240240
const SizedBox(width: denseSpacing),
241241
Flexible(
242-
child: FixedHeightOutlinedButton(
242+
child: OutlinedButton(
243243
onPressed: enableButtons ? _onResetClick : null,
244244
child: const Text(
245245
'Collapse to selected',

packages/devtools_app/lib/src/landing_screen.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class _LandingScreenBodyState extends State<LandingScreenBody> {
8888
'At this time, DevTools only supports importing files that were originally'
8989
' exported from DevTools.'),
9090
const SizedBox(height: defaultSpacing),
91-
FixedHeightElevatedButton(
91+
ElevatedButton(
9292
onPressed: _importFile,
9393
child: const MaterialIconLabel(
9494
label: 'Import File',
@@ -119,7 +119,7 @@ class _LandingScreenBodyState extends State<LandingScreenBody> {
119119
_captionText('Load Dart AOT snapshots or app size analysis files to '
120120
'track down size issues in your app.'),
121121
const SizedBox(height: defaultSpacing),
122-
FixedHeightElevatedButton(
122+
ElevatedButton(
123123
child: const Text('Open app size tool'),
124124
onPressed: () =>
125125
DevToolsRouterDelegate.of(context).navigate(appSizePageId),
@@ -185,7 +185,7 @@ class _LandingScreenBodyState extends State<LandingScreenBody> {
185185
),
186186
),
187187
const SizedBox(width: defaultSpacing),
188-
FixedHeightElevatedButton(
188+
ElevatedButton(
189189
child: const Text('Connect'),
190190
onPressed: connectDebounce.invoke,
191191
),

0 commit comments

Comments
 (0)