mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Follow-up to https://github.com/flutter/flutter/pull/167677 Addresses clean-up comments in cherry-pick: https://github.com/flutter/flutter/pull/168386
This commit is contained in:
parent
67ef841cae
commit
83082c19b7
@ -535,12 +535,12 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
Widget _exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return _CupertinoInspectorButton.filled(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
icon: CupertinoIcons.xmark,
|
||||
buttonKey: key,
|
||||
);
|
||||
@ -549,12 +549,12 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
Widget _moveExitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
bool isLeftAligned = true,
|
||||
}) {
|
||||
return _CupertinoInspectorButton.iconOnly(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
icon: isLeftAligned ? CupertinoIcons.arrow_right : CupertinoIcons.arrow_left,
|
||||
);
|
||||
}
|
||||
@ -562,12 +562,12 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
Widget _tapBehaviorButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required bool selectionOnTapEnabled,
|
||||
}) {
|
||||
return _CupertinoInspectorButton.toggle(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
// This icon is also used for the Material-styled button and for DevTools.
|
||||
// It should be updated in all 3 places if changed.
|
||||
icon: CupertinoIcons.cursor_rays,
|
||||
@ -685,21 +685,21 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
class _CupertinoInspectorButton extends InspectorButton {
|
||||
const _CupertinoInspectorButton.filled({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
super.buttonKey,
|
||||
}) : super.filled();
|
||||
|
||||
const _CupertinoInspectorButton.toggle({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
super.toggledOn,
|
||||
}) : super.toggle();
|
||||
|
||||
const _CupertinoInspectorButton.iconOnly({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
}) : super.iconOnly();
|
||||
|
||||
@ -707,7 +707,7 @@ class _CupertinoInspectorButton extends InspectorButton {
|
||||
Widget build(BuildContext context) {
|
||||
final Icon buttonIcon = Icon(
|
||||
icon,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticLabel: semanticsLabel,
|
||||
size: iconSizeForVariant,
|
||||
color: foregroundColor(context),
|
||||
);
|
||||
|
@ -29,7 +29,6 @@ import 'page.dart';
|
||||
import 'scaffold.dart' show ScaffoldMessenger, ScaffoldMessengerState;
|
||||
import 'scrollbar.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
import 'tooltip.dart';
|
||||
|
||||
// Examples can assume:
|
||||
@ -936,12 +935,12 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
Widget _exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return _MaterialInspectorButton.filled(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
icon: Icons.close,
|
||||
isDarkTheme: _isDarkTheme(context),
|
||||
buttonKey: key,
|
||||
@ -951,12 +950,12 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
Widget _moveExitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
bool isLeftAligned = true,
|
||||
}) {
|
||||
return _MaterialInspectorButton.iconOnly(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
icon: isLeftAligned ? Icons.arrow_right : Icons.arrow_left,
|
||||
isDarkTheme: _isDarkTheme(context),
|
||||
);
|
||||
@ -965,12 +964,12 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
Widget _tapBehaviorButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required bool selectionOnTapEnabled,
|
||||
}) {
|
||||
return _MaterialInspectorButton.toggle(
|
||||
onPressed: onPressed,
|
||||
semanticLabel: semanticLabel,
|
||||
semanticsLabel: semanticsLabel,
|
||||
// This icon is also used for the Cupertino-styled button and for DevTools.
|
||||
// It should be updated in all 3 places if changed.
|
||||
icon: CupertinoIcons.cursor_rays,
|
||||
@ -1172,7 +1171,7 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
class _MaterialInspectorButton extends InspectorButton {
|
||||
const _MaterialInspectorButton.filled({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
required this.isDarkTheme,
|
||||
super.buttonKey,
|
||||
@ -1180,7 +1179,7 @@ class _MaterialInspectorButton extends InspectorButton {
|
||||
|
||||
const _MaterialInspectorButton.toggle({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
required this.isDarkTheme,
|
||||
super.toggledOn,
|
||||
@ -1188,7 +1187,7 @@ class _MaterialInspectorButton extends InspectorButton {
|
||||
|
||||
const _MaterialInspectorButton.iconOnly({
|
||||
required super.onPressed,
|
||||
required super.semanticLabel,
|
||||
required super.semanticsLabel,
|
||||
required super.icon,
|
||||
required this.isDarkTheme,
|
||||
}) : super.iconOnly();
|
||||
@ -1210,7 +1209,7 @@ class _MaterialInspectorButton extends InspectorButton {
|
||||
padding: _buttonPadding,
|
||||
constraints: _buttonConstraints,
|
||||
style: _selectionButtonsIconStyle(context),
|
||||
icon: Icon(icon, semanticLabel: semanticLabel),
|
||||
icon: Icon(icon, semanticLabel: semanticsLabel),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1221,14 +1220,21 @@ class _MaterialInspectorButton extends InspectorButton {
|
||||
return IconButton.styleFrom(
|
||||
foregroundColor: foreground,
|
||||
backgroundColor: background,
|
||||
side:
|
||||
variant == InspectorButtonVariant.toggle && !toggledOn!
|
||||
? BorderSide(color: foreground)
|
||||
: null,
|
||||
side: _borderSide(color: foreground),
|
||||
tapTargetSize: MaterialTapTargetSize.padded,
|
||||
);
|
||||
}
|
||||
|
||||
BorderSide? _borderSide({required Color color}) {
|
||||
switch (variant) {
|
||||
case InspectorButtonVariant.filled:
|
||||
case InspectorButtonVariant.iconOnly:
|
||||
return null;
|
||||
case InspectorButtonVariant.toggle:
|
||||
return toggledOn == false ? BorderSide(color: color) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Color foregroundColor(BuildContext context) {
|
||||
final Color primaryColor = _primaryColor(context);
|
||||
|
@ -25,7 +25,6 @@ import 'colors.dart';
|
||||
import 'constants.dart';
|
||||
import 'material_button.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart' show MaterialTapTargetSize;
|
||||
|
||||
// Examples can assume:
|
||||
// late BuildContext context;
|
||||
|
@ -23,7 +23,6 @@ import 'material.dart';
|
||||
import 'material_localizations.dart';
|
||||
import 'text_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// enum Department { treasury, state }
|
||||
|
@ -20,7 +20,6 @@ import 'material_state.dart';
|
||||
import 'scaffold.dart';
|
||||
import 'text_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
import 'tooltip.dart';
|
||||
|
||||
class _DefaultHeroTag {
|
||||
|
@ -30,7 +30,6 @@ import 'material_state.dart';
|
||||
import 'popup_menu_theme.dart';
|
||||
import 'text_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
import 'tooltip.dart';
|
||||
|
||||
// Examples can assume:
|
||||
|
@ -34,7 +34,6 @@ import 'search_view_theme.dart';
|
||||
import 'text_field.dart';
|
||||
import 'text_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
const int _kOpenViewMilliseconds = 600;
|
||||
const Duration _kOpenViewDuration = Duration(milliseconds: _kOpenViewMilliseconds);
|
||||
|
@ -13,7 +13,6 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'material_state.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// late BuildContext context;
|
||||
|
@ -14,7 +14,7 @@ import 'material_localizations.dart';
|
||||
import 'theme_data.dart';
|
||||
import 'typography.dart';
|
||||
|
||||
export 'theme_data.dart' show Brightness, ThemeData;
|
||||
export 'theme_data.dart' show Brightness, MaterialTapTargetSize, ThemeData;
|
||||
|
||||
/// The duration over which theme changes animate by default.
|
||||
const Duration kThemeAnimationDuration = Duration(milliseconds: 200);
|
||||
|
@ -33,7 +33,6 @@ import 'text_button.dart';
|
||||
import 'text_form_field.dart';
|
||||
import 'text_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
import 'time.dart';
|
||||
import 'time_picker_theme.dart';
|
||||
|
||||
|
@ -44,7 +44,7 @@ typedef ExitWidgetSelectionButtonBuilder =
|
||||
Widget Function(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
});
|
||||
|
||||
@ -54,7 +54,7 @@ typedef MoveExitWidgetSelectionButtonBuilder =
|
||||
Widget Function(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
bool isLeftAligned,
|
||||
});
|
||||
|
||||
@ -64,7 +64,7 @@ typedef TapBehaviorButtonBuilder =
|
||||
Widget Function(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required bool selectionOnTapEnabled,
|
||||
});
|
||||
|
||||
@ -3054,7 +3054,7 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
const InspectorButton({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.semanticLabel,
|
||||
required this.semanticsLabel,
|
||||
required this.icon,
|
||||
this.buttonKey,
|
||||
required this.variant,
|
||||
@ -3067,7 +3067,7 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
const InspectorButton.filled({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.semanticLabel,
|
||||
required this.semanticsLabel,
|
||||
required this.icon,
|
||||
this.buttonKey,
|
||||
}) : variant = InspectorButtonVariant.filled,
|
||||
@ -3080,7 +3080,7 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
const InspectorButton.toggle({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.semanticLabel,
|
||||
required this.semanticsLabel,
|
||||
required this.icon,
|
||||
bool this.toggledOn = true,
|
||||
}) : buttonKey = null,
|
||||
@ -3092,7 +3092,7 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
const InspectorButton.iconOnly({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.semanticLabel,
|
||||
required this.semanticsLabel,
|
||||
required this.icon,
|
||||
}) : buttonKey = null,
|
||||
variant = InspectorButtonVariant.iconOnly,
|
||||
@ -3102,7 +3102,7 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
final VoidCallback onPressed;
|
||||
|
||||
/// The semantic label for the button, used for accessibility.
|
||||
final String semanticLabel;
|
||||
final String semanticsLabel;
|
||||
|
||||
/// The icon to display within the button.
|
||||
final IconData icon;
|
||||
@ -3131,8 +3131,15 @@ abstract class InspectorButton extends StatelessWidget {
|
||||
///
|
||||
/// Returns [buttonSize] if the variant is [InspectorButtonVariant.iconOnly],
|
||||
/// otherwise returns [buttonIconSize].
|
||||
double get iconSizeForVariant =>
|
||||
variant == InspectorButtonVariant.iconOnly ? buttonSize : buttonIconSize;
|
||||
double get iconSizeForVariant {
|
||||
switch (variant) {
|
||||
case InspectorButtonVariant.iconOnly:
|
||||
return buttonSize;
|
||||
case InspectorButtonVariant.filled:
|
||||
case InspectorButtonVariant.toggle:
|
||||
return buttonIconSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides the appropriate foreground color for the button's icon.
|
||||
Color foregroundColor(BuildContext context);
|
||||
@ -3656,7 +3663,7 @@ class _WidgetInspectorButtonGroupState extends State<_WidgetInspectorButtonGroup
|
||||
_changeButtonGroupAlignment();
|
||||
_onTooltipHidden();
|
||||
},
|
||||
semanticLabel: buttonLabel,
|
||||
semanticsLabel: buttonLabel,
|
||||
isLeftAligned: _leftAligned,
|
||||
),
|
||||
onTooltipVisible: () {
|
||||
@ -3672,7 +3679,7 @@ class _WidgetInspectorButtonGroupState extends State<_WidgetInspectorButtonGroup
|
||||
button: widget.exitWidgetSelectionButtonBuilder(
|
||||
context,
|
||||
onPressed: _exitWidgetSelectionMode,
|
||||
semanticLabel: buttonLabel,
|
||||
semanticsLabel: buttonLabel,
|
||||
key: _exitWidgetSelectionButtonKey,
|
||||
),
|
||||
onTooltipVisible: () {
|
||||
@ -3692,7 +3699,7 @@ class _WidgetInspectorButtonGroupState extends State<_WidgetInspectorButtonGroup
|
||||
button: buttonBuilder(
|
||||
context,
|
||||
onPressed: _changeSelectionOnTapMode,
|
||||
semanticLabel: 'Change widget selection mode for taps',
|
||||
semanticsLabel: 'Change widget selection mode for taps',
|
||||
selectionOnTapEnabled: _selectionOnTapEnabled.value,
|
||||
),
|
||||
onTooltipVisible: _changeSelectionOnTapTooltip,
|
||||
|
@ -375,7 +375,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
exitWidgetSelectionButtonKey = key;
|
||||
@ -553,7 +553,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
exitWidgetSelectionButtonKey = key;
|
||||
@ -807,7 +807,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
return (
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return Material(child: ElevatedButton(onPressed: onPressed, key: key, child: null));
|
||||
@ -898,7 +898,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return Material(child: ElevatedButton(onPressed: onPressed, key: key, child: null));
|
||||
@ -960,7 +960,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return Material(
|
||||
@ -975,7 +975,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget moveWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
bool isLeftAligned = true,
|
||||
}) {
|
||||
return Material(
|
||||
@ -1041,7 +1041,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget exitWidgetSelectionButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required GlobalKey key,
|
||||
}) {
|
||||
return Material(child: ElevatedButton(onPressed: onPressed, key: key, child: null));
|
||||
@ -1050,7 +1050,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
Widget tapBehaviorButtonBuilder(
|
||||
BuildContext context, {
|
||||
required VoidCallback onPressed,
|
||||
required String semanticLabel,
|
||||
required String semanticsLabel,
|
||||
required bool selectionOnTapEnabled,
|
||||
}) {
|
||||
return Material(
|
||||
|
Loading…
Reference in New Issue
Block a user