mirror of
https://github.com/flutter/flutter
synced 2024-09-13 05:11:45 +00:00
Implement switch
expressions in lib/src/material/
(#142634)
This PR is step 5 in the journey to solve issue #136139 and make the entire Flutter repo more readable. (previous pull requests: #139048, #139882, #141591, #142279) The current focus is on `packages/flutter/lib/src/material/`. The previous PR covered files in this directory starting with `a`, `b`, and `c`; this pull request is for `d` through `m`.
This commit is contained in:
parent
81574cba85
commit
5b947c889b
|
@ -119,13 +119,10 @@ class _DropdownMenuItemButton<T> extends StatefulWidget {
|
||||||
|
|
||||||
class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>> {
|
class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>> {
|
||||||
void _handleFocusChange(bool focused) {
|
void _handleFocusChange(bool focused) {
|
||||||
final bool inTraditionalMode;
|
final bool inTraditionalMode = switch (FocusManager.instance.highlightMode) {
|
||||||
switch (FocusManager.instance.highlightMode) {
|
FocusHighlightMode.touch => false,
|
||||||
case FocusHighlightMode.touch:
|
FocusHighlightMode.traditional => true,
|
||||||
inTraditionalMode = false;
|
};
|
||||||
case FocusHighlightMode.traditional:
|
|
||||||
inTraditionalMode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (focused && inTraditionalMode) {
|
if (focused && inTraditionalMode) {
|
||||||
final _MenuLimits menuLimits = widget.route.getMenuLimits(
|
final _MenuLimits menuLimits = widget.route.getMenuLimits(
|
||||||
|
@ -377,13 +374,10 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
|
||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
assert(textDirection != null);
|
assert(textDirection != null);
|
||||||
final double left;
|
final double left = switch (textDirection!) {
|
||||||
switch (textDirection!) {
|
TextDirection.rtl => clampDouble(buttonRect.right, 0.0, size.width) - childSize.width,
|
||||||
case TextDirection.rtl:
|
TextDirection.ltr => clampDouble(buttonRect.left, 0.0, size.width - childSize.width),
|
||||||
left = clampDouble(buttonRect.right, 0.0, size.width) - childSize.width;
|
};
|
||||||
case TextDirection.ltr:
|
|
||||||
left = clampDouble(buttonRect.left, 0.0, size.width - childSize.width);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Offset(left, menuLimits.top);
|
return Offset(left, menuLimits.top);
|
||||||
}
|
}
|
||||||
|
@ -1379,28 +1373,17 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||||
|
|
||||||
Color get _iconColor {
|
Color get _iconColor {
|
||||||
// These colors are not defined in the Material Design spec.
|
// These colors are not defined in the Material Design spec.
|
||||||
|
final Brightness brightness = Theme.of(context).brightness;
|
||||||
if (_enabled) {
|
if (_enabled) {
|
||||||
if (widget.iconEnabledColor != null) {
|
return widget.iconEnabledColor ?? switch (brightness) {
|
||||||
return widget.iconEnabledColor!;
|
Brightness.light => Colors.grey.shade700,
|
||||||
}
|
Brightness.dark => Colors.white70,
|
||||||
|
};
|
||||||
switch (Theme.of(context).brightness) {
|
|
||||||
case Brightness.light:
|
|
||||||
return Colors.grey.shade700;
|
|
||||||
case Brightness.dark:
|
|
||||||
return Colors.white70;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (widget.iconDisabledColor != null) {
|
return widget.iconDisabledColor ?? switch (brightness) {
|
||||||
return widget.iconDisabledColor!;
|
Brightness.light => Colors.grey.shade400,
|
||||||
}
|
Brightness.dark => Colors.white10,
|
||||||
|
};
|
||||||
switch (Theme.of(context).brightness) {
|
|
||||||
case Brightness.light:
|
|
||||||
return Colors.grey.shade400;
|
|
||||||
case Brightness.dark:
|
|
||||||
return Colors.white10;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -546,17 +546,10 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
|
||||||
// paddings so its leading icon will be aligned with the leading icon of
|
// paddings so its leading icon will be aligned with the leading icon of
|
||||||
// the text field.
|
// the text field.
|
||||||
final double padding = entry.leadingIcon == null ? (leadingPadding ?? _kDefaultHorizontalPadding) : _kDefaultHorizontalPadding;
|
final double padding = entry.leadingIcon == null ? (leadingPadding ?? _kDefaultHorizontalPadding) : _kDefaultHorizontalPadding;
|
||||||
final ButtonStyle defaultStyle;
|
final ButtonStyle defaultStyle = switch (textDirection) {
|
||||||
switch (textDirection) {
|
TextDirection.rtl => MenuItemButton.styleFrom(padding: EdgeInsets.only(left: _kDefaultHorizontalPadding, right: padding)),
|
||||||
case TextDirection.rtl:
|
TextDirection.ltr => MenuItemButton.styleFrom(padding: EdgeInsets.only(left: padding, right: _kDefaultHorizontalPadding)),
|
||||||
defaultStyle = MenuItemButton.styleFrom(
|
};
|
||||||
padding: EdgeInsets.only(left: _kDefaultHorizontalPadding, right: padding),
|
|
||||||
);
|
|
||||||
case TextDirection.ltr:
|
|
||||||
defaultStyle = MenuItemButton.styleFrom(
|
|
||||||
padding: EdgeInsets.only(left: padding, right: _kDefaultHorizontalPadding),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonStyle effectiveStyle = entry.style ?? defaultStyle;
|
ButtonStyle effectiveStyle = entry.style ?? defaultStyle;
|
||||||
final Color focusedBackgroundColor = effectiveStyle.foregroundColor?.resolve(<MaterialState>{MaterialState.focused})
|
final Color focusedBackgroundColor = effectiveStyle.foregroundColor?.resolve(<MaterialState>{MaterialState.focused})
|
||||||
|
|
|
@ -152,12 +152,10 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
|
||||||
return widget.color!;
|
return widget.color!;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Theme.of(context).brightness) {
|
return switch (Theme.of(context).brightness) {
|
||||||
case Brightness.light:
|
Brightness.light => Colors.black54,
|
||||||
return Colors.black54;
|
Brightness.dark => Colors.white60,
|
||||||
case Brightness.dark:
|
};
|
||||||
return Colors.white60;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -425,12 +425,10 @@ class FilledButton extends ButtonStyleButton {
|
||||||
/// [padding] is reduced from 24 to 16.
|
/// [padding] is reduced from 24 to 16.
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
switch (_variant) {
|
return switch (_variant) {
|
||||||
case _FilledButtonVariant.filled:
|
_FilledButtonVariant.filled => _FilledButtonDefaultsM3(context),
|
||||||
return _FilledButtonDefaultsM3(context);
|
_FilledButtonVariant.tonal => _FilledTonalButtonDefaultsM3(context),
|
||||||
case _FilledButtonVariant.tonal:
|
};
|
||||||
return _FilledTonalButtonDefaultsM3(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [FilledButtonThemeData.style] of the closest
|
/// Returns the [FilledButtonThemeData.style] of the closest
|
||||||
|
|
|
@ -185,32 +185,20 @@ class FlexibleSpaceBar extends StatefulWidget {
|
||||||
|
|
||||||
class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
|
class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
|
||||||
bool _getEffectiveCenterTitle(ThemeData theme) {
|
bool _getEffectiveCenterTitle(ThemeData theme) {
|
||||||
if (widget.centerTitle != null) {
|
return widget.centerTitle ?? switch (theme.platform) {
|
||||||
return widget.centerTitle!;
|
TargetPlatform.android || TargetPlatform.fuchsia || TargetPlatform.linux || TargetPlatform.windows => false,
|
||||||
}
|
TargetPlatform.iOS || TargetPlatform.macOS => true,
|
||||||
switch (theme.platform) {
|
};
|
||||||
case TargetPlatform.android:
|
|
||||||
case TargetPlatform.fuchsia:
|
|
||||||
case TargetPlatform.linux:
|
|
||||||
case TargetPlatform.windows:
|
|
||||||
return false;
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
case TargetPlatform.macOS:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Alignment _getTitleAlignment(bool effectiveCenterTitle) {
|
Alignment _getTitleAlignment(bool effectiveCenterTitle) {
|
||||||
if (effectiveCenterTitle) {
|
if (effectiveCenterTitle) {
|
||||||
return Alignment.bottomCenter;
|
return Alignment.bottomCenter;
|
||||||
}
|
}
|
||||||
final TextDirection textDirection = Directionality.of(context);
|
return switch (Directionality.of(context)) {
|
||||||
switch (textDirection) {
|
TextDirection.rtl => Alignment.bottomRight,
|
||||||
case TextDirection.rtl:
|
TextDirection.ltr => Alignment.bottomLeft,
|
||||||
return Alignment.bottomRight;
|
};
|
||||||
case TextDirection.ltr:
|
|
||||||
return Alignment.bottomLeft;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double _getCollapsePadding(double t, FlexibleSpaceBarSettings settings) {
|
double _getCollapsePadding(double t, FlexibleSpaceBarSettings settings) {
|
||||||
|
|
|
@ -814,26 +814,22 @@ class _FABDefaultsM3 extends FloatingActionButtonThemeData {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ShapeBorder? get shape {
|
ShapeBorder? get shape {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case _FloatingActionButtonType.regular:
|
_FloatingActionButtonType.regular => const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0))),
|
||||||
return const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0)));
|
_FloatingActionButtonType.small => const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12.0))),
|
||||||
case _FloatingActionButtonType.small:
|
_FloatingActionButtonType.large => const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(28.0))),
|
||||||
return const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12.0)));
|
_FloatingActionButtonType.extended => const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0))),
|
||||||
case _FloatingActionButtonType.large:
|
};
|
||||||
return const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(28.0)));
|
|
||||||
case _FloatingActionButtonType.extended:
|
|
||||||
return const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double? get iconSize {
|
double? get iconSize {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case _FloatingActionButtonType.regular: return 24.0;
|
_FloatingActionButtonType.regular => 24.0,
|
||||||
case _FloatingActionButtonType.small: return 24.0;
|
_FloatingActionButtonType.small => 24.0,
|
||||||
case _FloatingActionButtonType.large: return 36.0;
|
_FloatingActionButtonType.large => 36.0,
|
||||||
case _FloatingActionButtonType.extended: return 24.0;
|
_FloatingActionButtonType.extended => 24.0,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override EdgeInsetsGeometry? get extendedPadding => EdgeInsetsDirectional.only(start: hasChild && _isExtended ? 16.0 : 20.0, end: 20.0);
|
@override EdgeInsetsGeometry? get extendedPadding => EdgeInsetsDirectional.only(start: hasChild && _isExtended ? 16.0 : 20.0, end: 20.0);
|
||||||
|
|
|
@ -656,12 +656,10 @@ mixin FabStartOffsetX on StandardFabLocation {
|
||||||
/// Calculates x-offset for start-aligned [FloatingActionButtonLocation]s.
|
/// Calculates x-offset for start-aligned [FloatingActionButtonLocation]s.
|
||||||
@override
|
@override
|
||||||
double getOffsetX(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) {
|
double getOffsetX(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) {
|
||||||
switch (scaffoldGeometry.textDirection) {
|
return switch (scaffoldGeometry.textDirection) {
|
||||||
case TextDirection.rtl:
|
TextDirection.rtl => StandardFabLocation._rightOffsetX(scaffoldGeometry, adjustment),
|
||||||
return StandardFabLocation._rightOffsetX(scaffoldGeometry, adjustment);
|
TextDirection.ltr => StandardFabLocation._leftOffsetX(scaffoldGeometry, adjustment),
|
||||||
case TextDirection.ltr:
|
};
|
||||||
return StandardFabLocation._leftOffsetX(scaffoldGeometry, adjustment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,12 +677,10 @@ mixin FabEndOffsetX on StandardFabLocation {
|
||||||
/// Calculates x-offset for end-aligned [FloatingActionButtonLocation]s.
|
/// Calculates x-offset for end-aligned [FloatingActionButtonLocation]s.
|
||||||
@override
|
@override
|
||||||
double getOffsetX(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) {
|
double getOffsetX(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) {
|
||||||
switch (scaffoldGeometry.textDirection) {
|
return switch (scaffoldGeometry.textDirection) {
|
||||||
case TextDirection.rtl:
|
TextDirection.rtl => StandardFabLocation._leftOffsetX(scaffoldGeometry, adjustment),
|
||||||
return StandardFabLocation._leftOffsetX(scaffoldGeometry, adjustment);
|
TextDirection.ltr => StandardFabLocation._rightOffsetX(scaffoldGeometry, adjustment),
|
||||||
case TextDirection.ltr:
|
};
|
||||||
return StandardFabLocation._rightOffsetX(scaffoldGeometry, adjustment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -944,16 +944,12 @@ class _IconButtonM3 extends ButtonStyleButton {
|
||||||
/// * `splashFactory` - Theme.splashFactory
|
/// * `splashFactory` - Theme.splashFactory
|
||||||
@override
|
@override
|
||||||
ButtonStyle defaultStyleOf(BuildContext context) {
|
ButtonStyle defaultStyleOf(BuildContext context) {
|
||||||
switch (variant) {
|
return switch (variant) {
|
||||||
case _IconButtonVariant.filled:
|
_IconButtonVariant.filled => _FilledIconButtonDefaultsM3(context, toggleable),
|
||||||
return _FilledIconButtonDefaultsM3(context, toggleable);
|
_IconButtonVariant.filledTonal => _FilledTonalIconButtonDefaultsM3(context, toggleable),
|
||||||
case _IconButtonVariant.filledTonal:
|
_IconButtonVariant.outlined => _OutlinedIconButtonDefaultsM3(context, toggleable),
|
||||||
return _FilledTonalIconButtonDefaultsM3(context, toggleable);
|
_IconButtonVariant.standard => _IconButtonDefaultsM3(context, toggleable),
|
||||||
case _IconButtonVariant.outlined:
|
};
|
||||||
return _OutlinedIconButtonDefaultsM3(context, toggleable);
|
|
||||||
case _IconButtonVariant.standard:
|
|
||||||
return _IconButtonDefaultsM3(context, toggleable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [IconButtonThemeData.style] of the closest [IconButtonTheme] ancestor.
|
/// Returns the [IconButtonThemeData.style] of the closest [IconButtonTheme] ancestor.
|
||||||
|
|
|
@ -1373,13 +1373,10 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
|
||||||
width: overallWidth - _boxSize(icon).width,
|
width: overallWidth - _boxSize(icon).width,
|
||||||
);
|
);
|
||||||
container.layout(containerConstraints, parentUsesSize: true);
|
container.layout(containerConstraints, parentUsesSize: true);
|
||||||
final double x;
|
final double x = switch (textDirection) {
|
||||||
switch (textDirection) {
|
TextDirection.rtl => 0.0,
|
||||||
case TextDirection.rtl:
|
TextDirection.ltr => _boxSize(icon).width,
|
||||||
x = 0.0;
|
};
|
||||||
case TextDirection.ltr:
|
|
||||||
x = _boxSize(icon).width;
|
|
||||||
}
|
|
||||||
_boxParentData(container).offset = Offset(x, 0.0);
|
_boxParentData(container).offset = Offset(x, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1402,13 +1399,10 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
|
||||||
baseline = _isOutlineAligned ? layout.outlineBaseline : layout.inputBaseline;
|
baseline = _isOutlineAligned ? layout.outlineBaseline : layout.inputBaseline;
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
final double x;
|
final double x = switch (textDirection) {
|
||||||
switch (textDirection) {
|
TextDirection.rtl => overallWidth - icon!.size.width,
|
||||||
case TextDirection.rtl:
|
TextDirection.ltr => 0.0,
|
||||||
x = overallWidth - icon!.size.width;
|
};
|
||||||
case TextDirection.ltr:
|
|
||||||
x = 0.0;
|
|
||||||
}
|
|
||||||
centerLayout(icon!, x);
|
centerLayout(icon!, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,30 +1667,19 @@ class _Decorator extends SlottedMultiChildRenderObjectWidget<_DecorationSlot, Re
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget? childForSlot(_DecorationSlot slot) {
|
Widget? childForSlot(_DecorationSlot slot) {
|
||||||
switch (slot) {
|
return switch (slot) {
|
||||||
case _DecorationSlot.icon:
|
_DecorationSlot.icon => decoration.icon,
|
||||||
return decoration.icon;
|
_DecorationSlot.input => decoration.input,
|
||||||
case _DecorationSlot.input:
|
_DecorationSlot.label => decoration.label,
|
||||||
return decoration.input;
|
_DecorationSlot.hint => decoration.hint,
|
||||||
case _DecorationSlot.label:
|
_DecorationSlot.prefix => decoration.prefix,
|
||||||
return decoration.label;
|
_DecorationSlot.suffix => decoration.suffix,
|
||||||
case _DecorationSlot.hint:
|
_DecorationSlot.prefixIcon => decoration.prefixIcon,
|
||||||
return decoration.hint;
|
_DecorationSlot.suffixIcon => decoration.suffixIcon,
|
||||||
case _DecorationSlot.prefix:
|
_DecorationSlot.helperError => decoration.helperError,
|
||||||
return decoration.prefix;
|
_DecorationSlot.counter => decoration.counter,
|
||||||
case _DecorationSlot.suffix:
|
_DecorationSlot.container => decoration.container,
|
||||||
return decoration.suffix;
|
};
|
||||||
case _DecorationSlot.prefixIcon:
|
|
||||||
return decoration.prefixIcon;
|
|
||||||
case _DecorationSlot.suffixIcon:
|
|
||||||
return decoration.suffixIcon;
|
|
||||||
case _DecorationSlot.helperError:
|
|
||||||
return decoration.helperError;
|
|
||||||
case _DecorationSlot.counter:
|
|
||||||
return decoration.counter;
|
|
||||||
case _DecorationSlot.container:
|
|
||||||
return decoration.container;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -4558,22 +4541,12 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color? get fillColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
Color? get fillColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||||
if (states.contains(MaterialState.disabled)) {
|
return switch ((Theme.of(context).brightness, states.contains(MaterialState.disabled))) {
|
||||||
// dark theme: 5% white
|
(Brightness.dark, true) => const Color(0x0DFFFFFF), // 5% white
|
||||||
// light theme: 2% black
|
(Brightness.dark, false) => const Color(0x1AFFFFFF), // 10% white
|
||||||
switch (Theme.of(context).brightness) {
|
(Brightness.light, true) => const Color(0x05000000), // 2% black
|
||||||
case Brightness.dark:
|
(Brightness.light, false) => const Color(0x0A000000), // 4% black
|
||||||
return const Color(0x0DFFFFFF);
|
};
|
||||||
case Brightness.light:
|
|
||||||
return const Color(0x05000000) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dark theme: 10% white
|
|
||||||
// light theme: 4% black
|
|
||||||
switch (Theme.of(context).brightness) {
|
|
||||||
case Brightness.dark: return const Color(0x1AFFFFFF);
|
|
||||||
case Brightness.light:return const Color(0x0A000000) ;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -4584,12 +4557,10 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
if (states.contains(MaterialState.focused)) {
|
if (states.contains(MaterialState.focused)) {
|
||||||
return Theme.of(context).colorScheme.primary;
|
return Theme.of(context).colorScheme.primary;
|
||||||
}
|
}
|
||||||
switch (Theme.of(context).brightness) {
|
return switch (Theme.of(context).brightness) {
|
||||||
case Brightness.dark:
|
Brightness.dark => Colors.white70,
|
||||||
return Colors.white70;
|
Brightness.light => Colors.black45,
|
||||||
case Brightness.light:
|
};
|
||||||
return Colors.black45;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -4600,12 +4571,10 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
if (states.contains(MaterialState.focused)) {
|
if (states.contains(MaterialState.focused)) {
|
||||||
return Theme.of(context).colorScheme.primary;
|
return Theme.of(context).colorScheme.primary;
|
||||||
}
|
}
|
||||||
switch (Theme.of(context).brightness) {
|
return switch (Theme.of(context).brightness) {
|
||||||
case Brightness.dark:
|
Brightness.dark => Colors.white70,
|
||||||
return Colors.white70;
|
Brightness.light => Colors.black45,
|
||||||
case Brightness.light:
|
};
|
||||||
return Colors.black45;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -4616,12 +4585,10 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||||
if (states.contains(MaterialState.focused)) {
|
if (states.contains(MaterialState.focused)) {
|
||||||
return Theme.of(context).colorScheme.primary;
|
return Theme.of(context).colorScheme.primary;
|
||||||
}
|
}
|
||||||
switch (Theme.of(context).brightness) {
|
return switch (Theme.of(context).brightness) {
|
||||||
case Brightness.dark:
|
Brightness.dark => Colors.white70,
|
||||||
return Colors.white70;
|
Brightness.light => Colors.black45,
|
||||||
case Brightness.light:
|
};
|
||||||
return Colors.black45;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1002,16 +1002,12 @@ class _ListTile extends SlottedMultiChildRenderObjectWidget<_ListTileSlot, Rende
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget? childForSlot(_ListTileSlot slot) {
|
Widget? childForSlot(_ListTileSlot slot) {
|
||||||
switch (slot) {
|
return switch (slot) {
|
||||||
case _ListTileSlot.leading:
|
_ListTileSlot.leading => leading,
|
||||||
return leading;
|
_ListTileSlot.title => title,
|
||||||
case _ListTileSlot.title:
|
_ListTileSlot.subtitle => subtitle,
|
||||||
return title;
|
_ListTileSlot.trailing => trailing,
|
||||||
case _ListTileSlot.subtitle:
|
};
|
||||||
return subtitle;
|
|
||||||
case _ListTileSlot.trailing:
|
|
||||||
return trailing;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1521,12 +1517,10 @@ class _LisTileDefaultsM2 extends ListTileThemeData {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextStyle? get titleTextStyle {
|
TextStyle? get titleTextStyle {
|
||||||
switch (style!) {
|
return switch (style!) {
|
||||||
case ListTileStyle.drawer:
|
ListTileStyle.drawer => _textTheme.bodyLarge,
|
||||||
return _textTheme.bodyLarge;
|
ListTileStyle.list => _textTheme.titleMedium,
|
||||||
case ListTileStyle.list:
|
};
|
||||||
return _textTheme.titleMedium;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -994,12 +994,10 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||||
String get inputTimeModeButtonLabel => 'Switch to text input mode';
|
String get inputTimeModeButtonLabel => 'Switch to text input mode';
|
||||||
|
|
||||||
String _formatDayPeriod(TimeOfDay timeOfDay) {
|
String _formatDayPeriod(TimeOfDay timeOfDay) {
|
||||||
switch (timeOfDay.period) {
|
return switch (timeOfDay.period) {
|
||||||
case DayPeriod.am:
|
DayPeriod.am => anteMeridiemAbbreviation,
|
||||||
return anteMeridiemAbbreviation;
|
DayPeriod.pm => postMeridiemAbbreviation,
|
||||||
case DayPeriod.pm:
|
};
|
||||||
return postMeridiemAbbreviation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1128,14 +1126,11 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||||
@override
|
@override
|
||||||
String licensesPackageDetailText(int licenseCount) {
|
String licensesPackageDetailText(int licenseCount) {
|
||||||
assert(licenseCount >= 0);
|
assert(licenseCount >= 0);
|
||||||
switch (licenseCount) {
|
return switch (licenseCount) {
|
||||||
case 0:
|
0 => 'No licenses.',
|
||||||
return 'No licenses.';
|
1 => '1 license.',
|
||||||
case 1:
|
_ => '$licenseCount licenses.',
|
||||||
return '1 license.';
|
};
|
||||||
default:
|
|
||||||
return '$licenseCount licenses.';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1157,14 +1152,11 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String selectedRowCountTitle(int selectedRowCount) {
|
String selectedRowCountTitle(int selectedRowCount) {
|
||||||
switch (selectedRowCount) {
|
return switch (selectedRowCount) {
|
||||||
case 0:
|
0 => 'No items selected',
|
||||||
return 'No items selected';
|
1 => '1 item selected',
|
||||||
case 1:
|
_ => '$selectedRowCount items selected',
|
||||||
return '1 item selected';
|
};
|
||||||
default:
|
|
||||||
return '$selectedRowCount items selected';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1307,14 +1299,11 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String remainingTextFieldCharacterCount(int remaining) {
|
String remainingTextFieldCharacterCount(int remaining) {
|
||||||
switch (remaining) {
|
return switch (remaining) {
|
||||||
case 0:
|
0 => 'No characters remaining',
|
||||||
return 'No characters remaining';
|
1 => '1 character remaining',
|
||||||
case 1:
|
_ => '$remaining characters remaining',
|
||||||
return '1 character remaining';
|
};
|
||||||
default:
|
|
||||||
return '$remaining characters remaining';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -1871,19 +1871,15 @@ class _SubmenuButtonState extends State<SubmenuButton> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Offset menuPaddingOffset = widget.alignmentOffset ?? Offset.zero;
|
Offset menuPaddingOffset = widget.alignmentOffset ?? Offset.zero;
|
||||||
final EdgeInsets menuPadding = _computeMenuPadding(context);
|
final EdgeInsets menuPadding = _computeMenuPadding(context);
|
||||||
|
final Axis orientation = _anchor?._orientation ?? Axis.vertical;
|
||||||
// Move the submenu over by the size of the menu padding, so that
|
// Move the submenu over by the size of the menu padding, so that
|
||||||
// the first menu item aligns with the submenu button that opens it.
|
// the first menu item aligns with the submenu button that opens it.
|
||||||
switch (_anchor?._orientation ?? Axis.vertical) {
|
menuPaddingOffset += switch ((orientation, Directionality.of(context))) {
|
||||||
case Axis.horizontal:
|
(Axis.horizontal, TextDirection.rtl) => Offset(menuPadding.right, 0),
|
||||||
switch (Directionality.of(context)) {
|
(Axis.horizontal, TextDirection.ltr) => Offset(-menuPadding.left, 0),
|
||||||
case TextDirection.rtl:
|
(Axis.vertical, TextDirection.rtl) => Offset(0, -menuPadding.top),
|
||||||
menuPaddingOffset += Offset(menuPadding.right, 0);
|
(Axis.vertical, TextDirection.ltr) => Offset(0, -menuPadding.top),
|
||||||
case TextDirection.ltr:
|
};
|
||||||
menuPaddingOffset += Offset(-menuPadding.left, 0);
|
|
||||||
}
|
|
||||||
case Axis.vertical:
|
|
||||||
menuPaddingOffset += Offset(0, -menuPadding.top);
|
|
||||||
}
|
|
||||||
|
|
||||||
return MenuAnchor(
|
return MenuAnchor(
|
||||||
controller: _menuController,
|
controller: _menuController,
|
||||||
|
@ -3204,12 +3200,10 @@ class _MenuLayout extends SingleChildLayoutDelegate {
|
||||||
Offset desiredPosition = alignment.resolve(textDirection).withinRect(anchorRect);
|
Offset desiredPosition = alignment.resolve(textDirection).withinRect(anchorRect);
|
||||||
final Offset directionalOffset;
|
final Offset directionalOffset;
|
||||||
if (alignment is AlignmentDirectional) {
|
if (alignment is AlignmentDirectional) {
|
||||||
switch (textDirection) {
|
directionalOffset = switch (textDirection) {
|
||||||
case TextDirection.rtl:
|
TextDirection.rtl => Offset(-alignmentOffset.dx, alignmentOffset.dy),
|
||||||
directionalOffset = Offset(-alignmentOffset.dx, alignmentOffset.dy);
|
TextDirection.ltr => alignmentOffset,
|
||||||
case TextDirection.ltr:
|
};
|
||||||
directionalOffset = alignmentOffset;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
directionalOffset = alignmentOffset;
|
directionalOffset = alignmentOffset;
|
||||||
}
|
}
|
||||||
|
@ -3493,12 +3487,10 @@ class _MenuPanelState extends State<_MenuPanel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _intrinsicCrossSize({required Widget child}) {
|
Widget _intrinsicCrossSize({required Widget child}) {
|
||||||
switch (widget.orientation) {
|
return switch (widget.orientation) {
|
||||||
case Axis.horizontal:
|
Axis.horizontal => IntrinsicHeight(child: child),
|
||||||
return IntrinsicHeight(child: child);
|
Axis.vertical => IntrinsicWidth(child: child),
|
||||||
case Axis.vertical:
|
};
|
||||||
return IntrinsicWidth(child: child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue