Revert "if
chains → switch
expressions" (#148556)
Reverts flutter/flutter#147793 Introduced https://github.com/flutter/flutter/issues/148548.
This commit is contained in:
parent
3695802295
commit
597462a3c4
@ -209,11 +209,13 @@ class ListItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _convertCountToStr(int count) {
|
String _convertCountToStr(int count) {
|
||||||
return switch (count) {
|
if (count < 10000) {
|
||||||
< 10000 => count.toString(),
|
return count.toString();
|
||||||
< 100000 => '${(count / 10000).toStringAsPrecision(2)}w',
|
} else if (count < 100000) {
|
||||||
_ => '${(count / 10000).floor()}w',
|
return '${(count / 10000).toStringAsPrecision(2)}w';
|
||||||
};
|
} else {
|
||||||
|
return '${(count / 10000).floor()}w';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUserInfo() {
|
Widget _buildUserInfo() {
|
||||||
|
@ -31,11 +31,13 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Row _buildRow() {
|
Row _buildRow() {
|
||||||
_isChecked = switch (_isChecked) {
|
if (_isChecked == null) {
|
||||||
null => true,
|
_isChecked = true;
|
||||||
true => false,
|
} else if (_isChecked!) {
|
||||||
false => null,
|
_isChecked = false;
|
||||||
};
|
} else {
|
||||||
|
_isChecked = null;
|
||||||
|
}
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: List<Widget>.generate(10, (int i) {
|
children: List<Widget>.generate(10, (int i) {
|
||||||
|
@ -255,14 +255,16 @@ class StartContext extends Context {
|
|||||||
if (atBranchPoint) {
|
if (atBranchPoint) {
|
||||||
return ReleaseType.BETA_INITIAL;
|
return ReleaseType.BETA_INITIAL;
|
||||||
}
|
}
|
||||||
if (releaseChannel != 'stable') {
|
|
||||||
return ReleaseType.BETA_HOTFIX;
|
if (releaseChannel == 'stable') {
|
||||||
|
if (lastVersion.type == VersionType.stable) {
|
||||||
|
return ReleaseType.STABLE_HOTFIX;
|
||||||
|
} else {
|
||||||
|
return ReleaseType.STABLE_INITIAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return switch (lastVersion.type) {
|
return ReleaseType.BETA_HOTFIX;
|
||||||
VersionType.stable => ReleaseType.STABLE_HOTFIX,
|
|
||||||
VersionType.development || VersionType.gitDescribe || VersionType.latest => ReleaseType.STABLE_INITIAL,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> run() async {
|
Future<void> run() async {
|
||||||
|
@ -307,11 +307,13 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight;
|
final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight;
|
||||||
_controller.fling(velocity: switch (flingVelocity) {
|
if (flingVelocity < 0.0) {
|
||||||
< 0.0 => math.max(2.0, -flingVelocity),
|
_controller.fling(velocity: math.max(2.0, -flingVelocity));
|
||||||
> 0.0 => math.min(-2.0, -flingVelocity),
|
} else if (flingVelocity > 0.0) {
|
||||||
_ => _controller.value < 0.5 ? -2.0 : 2.0,
|
_controller.fling(velocity: math.min(-2.0, -flingVelocity));
|
||||||
});
|
} else {
|
||||||
|
_controller.fling(velocity: _controller.value < 0.5 ? -2.0 : 2.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stacks a BackdropPanel, which displays the selected category, on top
|
// Stacks a BackdropPanel, which displays the selected category, on top
|
||||||
|
@ -184,18 +184,21 @@ class _ListDemoState extends State<ListDemo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildListTile(BuildContext context, String item) {
|
Widget buildListTile(BuildContext context, String item) {
|
||||||
final String? subtitle = switch (_itemType) {
|
Widget? secondary;
|
||||||
_MaterialListType.oneLine || _MaterialListType.oneLineWithAvatar || null => null,
|
if (_itemType == _MaterialListType.twoLine) {
|
||||||
_MaterialListType.twoLine => 'Additional item information.',
|
secondary = const Text('Additional item information.');
|
||||||
_MaterialListType.threeLine => 'Even more additional list item information appears on line three.',
|
} else if (_itemType == _MaterialListType.threeLine) {
|
||||||
};
|
secondary = const Text(
|
||||||
|
'Even more additional list item information appears on line three.',
|
||||||
|
);
|
||||||
|
}
|
||||||
return MergeSemantics(
|
return MergeSemantics(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
isThreeLine: _itemType == _MaterialListType.threeLine,
|
isThreeLine: _itemType == _MaterialListType.threeLine,
|
||||||
dense: _dense,
|
dense: _dense,
|
||||||
leading: _showAvatars != null ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null,
|
leading: _showAvatars != null ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null,
|
||||||
title: Text('This item represents $item.'),
|
title: Text('This item represents $item.'),
|
||||||
subtitle: subtitle != null ? Text(subtitle) : null,
|
subtitle: secondary,
|
||||||
trailing: _showIcons != null ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
|
trailing: _showIcons != null ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -246,11 +246,13 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
|||||||
}
|
}
|
||||||
|
|
||||||
final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight;
|
final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight;
|
||||||
_controller!.fling(velocity: switch (flingVelocity) {
|
if (flingVelocity < 0.0) {
|
||||||
< 0.0 => math.max(2.0, -flingVelocity),
|
_controller!.fling(velocity: math.max(2.0, -flingVelocity));
|
||||||
> 0.0 => math.min(-2.0, -flingVelocity),
|
} else if (flingVelocity > 0.0) {
|
||||||
_ => _controller!.value < 0.5 ? -2.0 : 2.0,
|
_controller!.fling(velocity: math.min(-2.0, -flingVelocity));
|
||||||
});
|
} else {
|
||||||
|
_controller!.fling(velocity: _controller!.value < 0.5 ? -2.0 : 2.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleFrontLayer() {
|
void _toggleFrontLayer() {
|
||||||
|
@ -337,14 +337,22 @@ class _HighlightSpan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextStyle? textStyle(SyntaxHighlighterStyle? style) {
|
TextStyle? textStyle(SyntaxHighlighterStyle? style) {
|
||||||
return switch (type) {
|
if (type == _HighlightType.number) {
|
||||||
_HighlightType.number => style!.numberStyle,
|
return style!.numberStyle;
|
||||||
_HighlightType.comment => style!.commentStyle,
|
} else if (type == _HighlightType.comment) {
|
||||||
_HighlightType.keyword => style!.keywordStyle,
|
return style!.commentStyle;
|
||||||
_HighlightType.string => style!.stringStyle,
|
} else if (type == _HighlightType.keyword) {
|
||||||
_HighlightType.punctuation => style!.punctuationStyle,
|
return style!.keywordStyle;
|
||||||
_HighlightType.klass => style!.classStyle,
|
} else if (type == _HighlightType.string) {
|
||||||
_HighlightType.constant => style!.constantStyle,
|
return style!.stringStyle;
|
||||||
};
|
} else if (type == _HighlightType.punctuation) {
|
||||||
|
return style!.punctuationStyle;
|
||||||
|
} else if (type == _HighlightType.klass) {
|
||||||
|
return style!.classStyle;
|
||||||
|
} else if (type == _HighlightType.constant) {
|
||||||
|
return style!.constantStyle;
|
||||||
|
} else {
|
||||||
|
return style!.baseStyle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,15 +416,20 @@ class _CardsDemoState extends State<CardsDemo> with RestorationMixin {
|
|||||||
for (final TravelDestination destination in destinations(context))
|
for (final TravelDestination destination in destinations(context))
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
child: switch (destination.cardType) {
|
child: (destination.cardType == CardType.standard)
|
||||||
CardType.standard => TravelDestinationItem(destination: destination),
|
? TravelDestinationItem(destination: destination)
|
||||||
CardType.tappable => TappableTravelDestinationItem(destination: destination),
|
: destination.cardType == CardType.tappable
|
||||||
CardType.selectable => SelectableTravelDestinationItem(
|
? TappableTravelDestinationItem(
|
||||||
destination: destination,
|
destination: destination)
|
||||||
isSelected: _isSelected.value,
|
: SelectableTravelDestinationItem(
|
||||||
onSelected: () => setState(() { _isSelected.value = !_isSelected.value; }),
|
destination: destination,
|
||||||
),
|
isSelected: _isSelected.value,
|
||||||
},
|
onSelected: () {
|
||||||
|
setState(() {
|
||||||
|
_isSelected.value = !_isSelected.value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -69,10 +69,13 @@ class TwoPaneDemoState extends State<TwoPaneDemo> with RestorationMixin {
|
|||||||
),
|
),
|
||||||
endPane: DetailsPane(
|
endPane: DetailsPane(
|
||||||
selectedIndex: _currentIndex.value,
|
selectedIndex: _currentIndex.value,
|
||||||
onClose: switch (widget.type) {
|
onClose: widget.type == TwoPaneDemoType.smallScreen
|
||||||
TwoPaneDemoType.smallScreen => () => setState(() { _currentIndex.value = -1; }),
|
? () {
|
||||||
TwoPaneDemoType.foldable || TwoPaneDemoType.tablet => null,
|
setState(() {
|
||||||
},
|
_currentIndex.value = -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -187,11 +190,11 @@ class SimulateScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(14),
|
padding: const EdgeInsets.all(14),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: switch (type) {
|
aspectRatio: type == TwoPaneDemoType.foldable
|
||||||
TwoPaneDemoType.foldable => foldableAspectRatio,
|
? foldableAspectRatio
|
||||||
TwoPaneDemoType.tablet => tabletAspectRatio,
|
: type == TwoPaneDemoType.tablet
|
||||||
TwoPaneDemoType.smallScreen => singleScreenAspectRatio,
|
? tabletAspectRatio
|
||||||
},
|
: singleScreenAspectRatio,
|
||||||
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
final Size size = Size(constraints.maxWidth, constraints.maxHeight);
|
final Size size = Size(constraints.maxWidth, constraints.maxHeight);
|
||||||
final Size hingeSize = Size(size.width * hingeProportion, size.height);
|
final Size hingeSize = Size(size.width * hingeProportion, size.height);
|
||||||
|
@ -34,12 +34,12 @@ class _SettingsIconPainter extends CustomPainter {
|
|||||||
///
|
///
|
||||||
/// The icon is aligned to the bottom-start corner.
|
/// The icon is aligned to the bottom-start corner.
|
||||||
void _computeCenterAndScaling(Size size) {
|
void _computeCenterAndScaling(Size size) {
|
||||||
final double dx = switch (Directionality.of(context)) {
|
|
||||||
TextDirection.rtl => size.width - unitWidth * _scaling / 2,
|
|
||||||
TextDirection.ltr => unitWidth * _scaling / 2,
|
|
||||||
};
|
|
||||||
_center = Offset(dx, size.height - unitHeight * _scaling / 2);
|
|
||||||
_scaling = min(size.width / unitWidth, size.height / unitHeight);
|
_scaling = min(size.width / unitWidth, size.height / unitHeight);
|
||||||
|
_center = Directionality.of(context) == TextDirection.ltr
|
||||||
|
? Offset(
|
||||||
|
unitWidth * _scaling / 2, size.height - unitHeight * _scaling / 2)
|
||||||
|
: Offset(size.width - unitWidth * _scaling / 2,
|
||||||
|
size.height - unitHeight * _scaling / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transforms an offset in relative units into an offset in logical pixels.
|
/// Transforms an offset in relative units into an offset in logical pixels.
|
||||||
|
@ -103,16 +103,21 @@ bool _findBGR10Color(
|
|||||||
return foundDeepRed;
|
return foundDeepRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _findColor(List<dynamic> result, List<double> color) {
|
bool _findColor(List<Object?> result, List<double> color) {
|
||||||
expect(result, isNotNull);
|
expect(result, isNotNull);
|
||||||
expect(result.length, 4);
|
expect(result.length, 4);
|
||||||
final [int width, int height, String format, Uint8List bytes] = result;
|
final int width = (result[0] as int?)!;
|
||||||
return switch (format) {
|
final int height = (result[1] as int?)!;
|
||||||
'MTLPixelFormatBGR10_XR' => _findBGR10Color(bytes, width, height, color),
|
final String format = (result[2] as String?)!;
|
||||||
'MTLPixelFormatBGRA10_XR' => _findBGRA10Color(bytes, width, height, color),
|
if (format == 'MTLPixelFormatBGR10_XR') {
|
||||||
'MTLPixelFormatRGBA16Float' => _findRGBAF16Color(bytes, width, height, color),
|
return _findBGR10Color((result[3] as Uint8List?)!, width, height, color);
|
||||||
_ => fail('Unsupported pixel format: $format'),
|
} else if (format == 'MTLPixelFormatBGRA10_XR') {
|
||||||
};
|
return _findBGRA10Color((result[3] as Uint8List?)!, width, height, color);
|
||||||
|
} else if (format == 'MTLPixelFormatRGBA16Float') {
|
||||||
|
return _findRGBAF16Color((result[3] as Uint8List?)!, width, height, color);
|
||||||
|
} else {
|
||||||
|
fail('Unsupported pixel format: $format');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -163,12 +163,14 @@ class _OptionsState extends State<Options> {
|
|||||||
double sliderValue = 0.0;
|
double sliderValue = 0.0;
|
||||||
|
|
||||||
String _densityToProfile(VisualDensity density) {
|
String _densityToProfile(VisualDensity density) {
|
||||||
return switch (density) {
|
if (density == VisualDensity.standard) {
|
||||||
VisualDensity.standard => 'standard',
|
return 'standard';
|
||||||
VisualDensity.compact => 'compact',
|
} else if (density == VisualDensity.compact) {
|
||||||
VisualDensity.comfortable => 'comfortable',
|
return 'compact';
|
||||||
_ => 'custom',
|
} else if (density == VisualDensity.comfortable) {
|
||||||
};
|
return 'comfortable';
|
||||||
|
}
|
||||||
|
return 'custom';
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualDensity _profileToDensity(String? profile) {
|
VisualDensity _profileToDensity(String? profile) {
|
||||||
|
@ -70,7 +70,9 @@ class PageViewAppState extends State<PageViewApp> {
|
|||||||
|
|
||||||
void switchScrollDirection() {
|
void switchScrollDirection() {
|
||||||
setState(() {
|
setState(() {
|
||||||
scrollDirection = flipAxis(scrollDirection);
|
scrollDirection = (scrollDirection == Axis.vertical)
|
||||||
|
? Axis.horizontal
|
||||||
|
: Axis.vertical;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +113,9 @@ class PageViewAppState extends State<PageViewApp> {
|
|||||||
AppBar _buildAppBar() {
|
AppBar _buildAppBar() {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
title: const Text('PageView'),
|
title: const Text('PageView'),
|
||||||
actions: <Widget>[Text(scrollDirection.name)],
|
actions: <Widget>[
|
||||||
|
Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,13 +169,16 @@ abstract class TokenTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String? _numToString(Object? value, [int? digits]) {
|
String? _numToString(Object? value, [int? digits]) {
|
||||||
return switch (value) {
|
if (value == null) {
|
||||||
null => null,
|
return null;
|
||||||
double.infinity => 'double.infinity',
|
}
|
||||||
num() when digits == null => value.toString(),
|
if (value is num) {
|
||||||
num() => value.toStringAsFixed(digits!),
|
if (value == double.infinity) {
|
||||||
_ => getToken(value as String).toString(),
|
return 'double.infinity';
|
||||||
};
|
}
|
||||||
|
return digits == null ? value.toString() : value.toStringAsFixed(digits);
|
||||||
|
}
|
||||||
|
return getToken(value as String).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate an elevation value for the given component token.
|
/// Generate an elevation value for the given component token.
|
||||||
|
@ -205,11 +205,18 @@ Map<String, String> reverseMapOfListOfString(Map<String, List<String>> inMap, vo
|
|||||||
///
|
///
|
||||||
/// Will modify the input map.
|
/// Will modify the input map.
|
||||||
Map<String, dynamic> removeEmptyValues(Map<String, dynamic> map) {
|
Map<String, dynamic> removeEmptyValues(Map<String, dynamic> map) {
|
||||||
return map..removeWhere((String key, dynamic value) => switch (value) {
|
return map..removeWhere((String key, dynamic value) {
|
||||||
null => true,
|
if (value == null) {
|
||||||
Map<String, dynamic>() => removeEmptyValues(value).isEmpty,
|
return true;
|
||||||
Iterable<dynamic>() => value.isEmpty,
|
}
|
||||||
_ => false,
|
if (value is Map<String, dynamic>) {
|
||||||
|
final Map<String, dynamic> regularizedMap = removeEmptyValues(value);
|
||||||
|
return regularizedMap.isEmpty;
|
||||||
|
}
|
||||||
|
if (value is Iterable<dynamic>) {
|
||||||
|
return value.isEmpty;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +123,13 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
|||||||
const Text('Multi Line Text'),
|
const Text('Multi Line Text'),
|
||||||
Switch(
|
Switch(
|
||||||
value: _multiLine,
|
value: _multiLine,
|
||||||
onChanged: switch (_snackBarBehavior) {
|
onChanged: _snackBarBehavior == SnackBarBehavior.fixed
|
||||||
SnackBarBehavior.fixed || null => null,
|
? null
|
||||||
SnackBarBehavior.floating => (bool value) => setState(() { _multiLine = !_multiLine; }),
|
: (bool value) {
|
||||||
},
|
setState(() {
|
||||||
|
_multiLine = !_multiLine;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -136,10 +139,13 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
|||||||
value: _sliderValue,
|
value: _sliderValue,
|
||||||
divisions: 20,
|
divisions: 20,
|
||||||
label: _sliderValue.toStringAsFixed(2),
|
label: _sliderValue.toStringAsFixed(2),
|
||||||
onChanged: switch (_snackBarBehavior) {
|
onChanged: _snackBarBehavior == SnackBarBehavior.fixed
|
||||||
SnackBarBehavior.fixed || null => null,
|
? null
|
||||||
SnackBarBehavior.floating => (double value) => setState(() { _sliderValue = value; }),
|
: (double value) {
|
||||||
},
|
setState(() {
|
||||||
|
_sliderValue = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
const SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
|
@ -91,14 +91,17 @@ class LinkedScrollController extends ScrollController {
|
|||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
super.debugFillDescription(description);
|
super.debugFillDescription(description);
|
||||||
final String linkSymbol = switch ((before, after)) {
|
if (before != null && after != null) {
|
||||||
(null, null) => 'none',
|
description.add('links: ⬌');
|
||||||
(null, _) => '➡',
|
} else if (before != null) {
|
||||||
(_, null) => '⬅',
|
description.add('links: ⬅');
|
||||||
(_, _) => '⬌',
|
} else if (after != null) {
|
||||||
};
|
description.add('links: ➡');
|
||||||
description.add('links: $linkSymbol');
|
} else {
|
||||||
|
description.add('links: none');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
||||||
|
@ -27,10 +27,11 @@ void main() {
|
|||||||
final AxisDirection axisDirection;
|
final AxisDirection axisDirection;
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
axisDirection = switch (textDirection) {
|
if (textDirection == TextDirection.rtl) {
|
||||||
TextDirection.rtl => reverse ? AxisDirection.right : AxisDirection.left,
|
axisDirection = reverse ? AxisDirection.right : AxisDirection.left;
|
||||||
TextDirection.ltr => reverse ? AxisDirection.left : AxisDirection.right,
|
} else {
|
||||||
};
|
axisDirection = reverse ? AxisDirection.left : AxisDirection.right;
|
||||||
|
}
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
axisDirection = reverse ? AxisDirection.up : AxisDirection.down;
|
axisDirection = reverse ? AxisDirection.up : AxisDirection.down;
|
||||||
}
|
}
|
||||||
|
@ -2722,11 +2722,13 @@ void main() {
|
|||||||
addAutomaticKeepAlives: false,
|
addAutomaticKeepAlives: false,
|
||||||
addRepaintBoundaries: false,
|
addRepaintBoundaries: false,
|
||||||
builder: (BuildContext context, ChildVicinity vicinity) {
|
builder: (BuildContext context, ChildVicinity vicinity) {
|
||||||
final ValueKey<int>? key = switch (vicinity) {
|
ValueKey<int>? key;
|
||||||
ChildVicinity(xIndex: 1, yIndex: 1) => const ValueKey<int>(1),
|
if (vicinity == const ChildVicinity(xIndex: 1, yIndex: 1)) {
|
||||||
ChildVicinity(xIndex: 1, yIndex: 2) => const ValueKey<int>(2),
|
key = const ValueKey<int>(1);
|
||||||
_ => null,
|
} else if (vicinity ==
|
||||||
};
|
const ChildVicinity(xIndex: 1, yIndex: 2)) {
|
||||||
|
key = const ValueKey<int>(2);
|
||||||
|
}
|
||||||
return SizedBox.square(key: key, dimension: 200);
|
return SizedBox.square(key: key, dimension: 200);
|
||||||
});
|
});
|
||||||
final TwoDimensionalChildBuilderDelegate delegate2 =
|
final TwoDimensionalChildBuilderDelegate delegate2 =
|
||||||
@ -2768,11 +2770,13 @@ void main() {
|
|||||||
addAutomaticKeepAlives: false,
|
addAutomaticKeepAlives: false,
|
||||||
addRepaintBoundaries: false,
|
addRepaintBoundaries: false,
|
||||||
builder: (BuildContext context, ChildVicinity vicinity) {
|
builder: (BuildContext context, ChildVicinity vicinity) {
|
||||||
final ValueKey<int>? key = switch (vicinity) {
|
ValueKey<int>? key;
|
||||||
ChildVicinity(xIndex: 0, yIndex: 0) => const ValueKey<int>(1),
|
if (vicinity == const ChildVicinity(xIndex: 1, yIndex: 1)) {
|
||||||
ChildVicinity(xIndex: 1, yIndex: 1) => const ValueKey<int>(2),
|
key = const ValueKey<int>(1);
|
||||||
_ => null,
|
} else if (vicinity ==
|
||||||
};
|
const ChildVicinity(xIndex: 1, yIndex: 2)) {
|
||||||
|
key = const ValueKey<int>(2);
|
||||||
|
}
|
||||||
return Checkbox(key: key, value: false, onChanged: (_) {});
|
return Checkbox(key: key, value: false, onChanged: (_) {});
|
||||||
});
|
});
|
||||||
final TwoDimensionalChildBuilderDelegate delegate2 =
|
final TwoDimensionalChildBuilderDelegate delegate2 =
|
||||||
|
@ -118,12 +118,19 @@ List<TimelineEvent>? _parseEvents(Map<String, dynamic> json) {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
timelineEvents.sort((TimelineEvent e1, TimelineEvent e2) {
|
timelineEvents.sort((TimelineEvent e1, TimelineEvent e2) {
|
||||||
return switch ((e1.timestampMicros, e2.timestampMicros)) {
|
final int? ts1 = e1.timestampMicros;
|
||||||
(null, null) => 0,
|
final int? ts2 = e2.timestampMicros;
|
||||||
(_, null) => 1,
|
if (ts1 == null) {
|
||||||
(null, _) => -1,
|
if (ts2 == null) {
|
||||||
(final int ts1, final int ts2) => ts1.compareTo(ts2),
|
return 0;
|
||||||
};
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (ts2 == null) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return ts1.compareTo(ts2);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return timelineEvents;
|
return timelineEvents;
|
||||||
|
@ -546,11 +546,12 @@ Matcher coversSameAreaAs(Path expectedPath, { required Rect areaToCompare, int s
|
|||||||
/// * [flutter_test] for a discussion of test configurations, whereby callers
|
/// * [flutter_test] for a discussion of test configurations, whereby callers
|
||||||
/// may swap out the backend for this matcher.
|
/// may swap out the backend for this matcher.
|
||||||
AsyncMatcher matchesGoldenFile(Object key, {int? version}) {
|
AsyncMatcher matchesGoldenFile(Object key, {int? version}) {
|
||||||
return switch (key) {
|
if (key is Uri) {
|
||||||
Uri() => MatchesGoldenFile(key, version),
|
return MatchesGoldenFile(key, version);
|
||||||
String() => MatchesGoldenFile.forStringPath(key, version),
|
} else if (key is String) {
|
||||||
_ => throw ArgumentError('Unexpected type for golden file: ${key.runtimeType}'),
|
return MatchesGoldenFile.forStringPath(key, version);
|
||||||
};
|
}
|
||||||
|
throw ArgumentError('Unexpected type for golden file: ${key.runtimeType}');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Asserts that a [Finder], [Future<ui.Image>], or [ui.Image] matches a
|
/// Asserts that a [Finder], [Future<ui.Image>], or [ui.Image] matches a
|
||||||
|
@ -932,11 +932,14 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
|||||||
|
|
||||||
final Key? key = widget.key;
|
final Key? key = widget.key;
|
||||||
if (key is ValueKey<dynamic>) {
|
if (key is ValueKey<dynamic>) {
|
||||||
final String? keyLabel = switch (key.value) {
|
String? keyLabel;
|
||||||
int() || double() || bool() => 'const ${key.runtimeType}(${key.value})',
|
if (key is ValueKey<int> ||
|
||||||
final String value => "const Key('$value')",
|
key is ValueKey<double> ||
|
||||||
_ => null,
|
key is ValueKey<bool>) {
|
||||||
};
|
keyLabel = 'const ${key.runtimeType}(${key.value})';
|
||||||
|
} else if (key is ValueKey<String>) {
|
||||||
|
keyLabel = "const Key('${key.value}')";
|
||||||
|
}
|
||||||
if (keyLabel != null) {
|
if (keyLabel != null) {
|
||||||
final Iterable<Element> matches = find.byKey(key).evaluate();
|
final Iterable<Element> matches = find.byKey(key).evaluate();
|
||||||
if (matches.length == 1) {
|
if (matches.length == 1) {
|
||||||
|
@ -131,11 +131,12 @@ abstract class DeferredComponentsValidator {
|
|||||||
if (line.startsWith('Only in android')) {
|
if (line.startsWith('Only in android')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final TerminalColor color = switch (line[0]) {
|
TerminalColor color = TerminalColor.grey;
|
||||||
'+' => TerminalColor.green,
|
if (line.startsWith('+')) {
|
||||||
'-' => TerminalColor.red,
|
color = TerminalColor.green;
|
||||||
_ => TerminalColor.grey,
|
} else if (line.startsWith('-')) {
|
||||||
};
|
color = TerminalColor.red;
|
||||||
|
}
|
||||||
logger.printStatus(line, color: color);
|
logger.printStatus(line, color: color);
|
||||||
}
|
}
|
||||||
logger.printStatus('');
|
logger.printStatus('');
|
||||||
|
@ -115,15 +115,18 @@ class MultiRootFileSystem extends ForwardingFileSystem {
|
|||||||
/// If the path is a multiroot uri, resolve to the actual path of the
|
/// If the path is a multiroot uri, resolve to the actual path of the
|
||||||
/// underlying file system. Otherwise, return as is.
|
/// underlying file system. Otherwise, return as is.
|
||||||
dynamic _resolve(dynamic path) {
|
dynamic _resolve(dynamic path) {
|
||||||
|
Uri uri;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return null;
|
return null;
|
||||||
|
} else if (path is String) {
|
||||||
|
uri = Uri.parse(path);
|
||||||
|
} else if (path is Uri) {
|
||||||
|
uri = path;
|
||||||
|
} else if (path is FileSystemEntity) {
|
||||||
|
uri = path.uri;
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Invalid type for "path": ${(path as Object?)?.runtimeType}');
|
||||||
}
|
}
|
||||||
final Uri uri = switch (path) {
|
|
||||||
String() => Uri.parse(path),
|
|
||||||
Uri() => path,
|
|
||||||
FileSystemEntity() => path.uri,
|
|
||||||
_ => throw ArgumentError('Invalid type for "path": ${(path as Object?)?.runtimeType}'),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!uri.hasScheme || uri.scheme != _scheme) {
|
if (!uri.hasScheme || uri.scheme != _scheme) {
|
||||||
return path;
|
return path;
|
||||||
|
@ -666,10 +666,11 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
|
|||||||
|
|
||||||
final String logTarget = environmentType == EnvironmentType.simulator ? 'simulator' : 'device';
|
final String logTarget = environmentType == EnvironmentType.simulator ? 'simulator' : 'device';
|
||||||
final String typeName = globals.artifacts!.getEngineType(TargetPlatform.ios, buildInfo.mode);
|
final String typeName = globals.artifacts!.getEngineType(TargetPlatform.ios, buildInfo.mode);
|
||||||
globals.printStatus(switch (xcodeBuildAction) {
|
if (xcodeBuildAction == XcodeBuildAction.build) {
|
||||||
XcodeBuildAction.build => 'Building $app for $logTarget ($typeName)...',
|
globals.printStatus('Building $app for $logTarget ($typeName)...');
|
||||||
XcodeBuildAction.archive => 'Archiving $app...',
|
} else {
|
||||||
});
|
globals.printStatus('Archiving $app...');
|
||||||
|
}
|
||||||
final XcodeBuildResult result = await buildXcodeProject(
|
final XcodeBuildResult result = await buildXcodeProject(
|
||||||
app: app,
|
app: app,
|
||||||
buildInfo: buildInfo,
|
buildInfo: buildInfo,
|
||||||
|
@ -429,17 +429,22 @@ end
|
|||||||
Directory simulatorBuildOutput,
|
Directory simulatorBuildOutput,
|
||||||
) async {
|
) async {
|
||||||
const String appFrameworkName = 'App.framework';
|
const String appFrameworkName = 'App.framework';
|
||||||
|
|
||||||
final Status status = globals.logger.startProgress(
|
final Status status = globals.logger.startProgress(
|
||||||
' ├─Building App.xcframework...',
|
' ├─Building App.xcframework...',
|
||||||
);
|
);
|
||||||
|
final List<EnvironmentType> environmentTypes = <EnvironmentType>[
|
||||||
|
EnvironmentType.physical,
|
||||||
|
EnvironmentType.simulator,
|
||||||
|
];
|
||||||
final List<Directory> frameworks = <Directory>[];
|
final List<Directory> frameworks = <Directory>[];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (final EnvironmentType sdkType in EnvironmentType.values) {
|
for (final EnvironmentType sdkType in environmentTypes) {
|
||||||
final Directory outputBuildDirectory = switch (sdkType) {
|
final Directory outputBuildDirectory =
|
||||||
EnvironmentType.physical => iPhoneBuildOutput,
|
sdkType == EnvironmentType.physical
|
||||||
EnvironmentType.simulator => simulatorBuildOutput,
|
? iPhoneBuildOutput
|
||||||
};
|
: simulatorBuildOutput;
|
||||||
frameworks.add(outputBuildDirectory.childDirectory(appFrameworkName));
|
frameworks.add(outputBuildDirectory.childDirectory(appFrameworkName));
|
||||||
final Environment environment = Environment(
|
final Environment environment = Environment(
|
||||||
projectDir: globals.fs.currentDirectory,
|
projectDir: globals.fs.currentDirectory,
|
||||||
|
@ -1429,12 +1429,16 @@ Map<String, Object?> _operationResultToMap(OperationResult result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object? _toJsonable(Object? obj) {
|
Object? _toJsonable(Object? obj) {
|
||||||
return switch (obj) {
|
if (obj is String || obj is int || obj is bool || obj is Map<Object?, Object?> || obj is List<Object?> || obj == null) {
|
||||||
String() || int() || bool() || Map<Object?, Object?>() || List<Object?>() || null => obj,
|
return obj;
|
||||||
OperationResult() => _operationResultToMap(obj),
|
}
|
||||||
ToolExit() => obj.message,
|
if (obj is OperationResult) {
|
||||||
_ => obj.toString(),
|
return _operationResultToMap(obj);
|
||||||
};
|
}
|
||||||
|
if (obj is ToolExit) {
|
||||||
|
return obj.message;
|
||||||
|
}
|
||||||
|
return '$obj';
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotifyingLogger extends DelegatingLogger {
|
class NotifyingLogger extends DelegatingLogger {
|
||||||
|
@ -942,11 +942,12 @@ enum ImpellerStatus {
|
|||||||
|
|
||||||
const ImpellerStatus._(this.asBool);
|
const ImpellerStatus._(this.asBool);
|
||||||
|
|
||||||
factory ImpellerStatus.fromBool(bool? b) => switch (b) {
|
factory ImpellerStatus.fromBool(bool? b) {
|
||||||
true => enabled,
|
if (b == null) {
|
||||||
false => disabled,
|
return platformDefault;
|
||||||
null => platformDefault,
|
}
|
||||||
};
|
return b ? enabled : disabled;
|
||||||
|
}
|
||||||
|
|
||||||
final bool? asBool;
|
final bool? asBool;
|
||||||
}
|
}
|
||||||
|
@ -439,11 +439,15 @@ class IOSCoreDevice {
|
|||||||
String? get udid => hardwareProperties?.udid;
|
String? get udid => hardwareProperties?.udid;
|
||||||
|
|
||||||
DeviceConnectionInterface? get connectionInterface {
|
DeviceConnectionInterface? get connectionInterface {
|
||||||
return switch (connectionProperties?.transportType?.toLowerCase()) {
|
final String? transportType = connectionProperties?.transportType;
|
||||||
'localnetwork' => DeviceConnectionInterface.wireless,
|
if (transportType != null) {
|
||||||
'wired' => DeviceConnectionInterface.attached,
|
if (transportType.toLowerCase() == 'localnetwork') {
|
||||||
_ => null,
|
return DeviceConnectionInterface.wireless;
|
||||||
};
|
} else if (transportType.toLowerCase() == 'wired') {
|
||||||
|
return DeviceConnectionInterface.attached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
|
@ -96,12 +96,16 @@ class Node {
|
|||||||
// Token constructors.
|
// Token constructors.
|
||||||
Node.openBrace(this.positionInMessage): type = ST.openBrace, value = '{';
|
Node.openBrace(this.positionInMessage): type = ST.openBrace, value = '{';
|
||||||
Node.closeBrace(this.positionInMessage): type = ST.closeBrace, value = '}';
|
Node.closeBrace(this.positionInMessage): type = ST.closeBrace, value = '}';
|
||||||
Node.brace(this.positionInMessage, String this.value)
|
Node.brace(this.positionInMessage, String this.value) {
|
||||||
: type = switch (value) {
|
if (value == '{') {
|
||||||
'{' => ST.openBrace,
|
type = ST.openBrace;
|
||||||
'}' => ST.closeBrace,
|
} else if (value == '}') {
|
||||||
_ => throw L10nException('Provided value $value is not a brace.')
|
type = ST.closeBrace;
|
||||||
};
|
} else {
|
||||||
|
// We should never arrive here.
|
||||||
|
throw L10nException('Provided value $value is not a brace.');
|
||||||
|
}
|
||||||
|
}
|
||||||
Node.equalSign(this.positionInMessage): type = ST.equalSign, value = '=';
|
Node.equalSign(this.positionInMessage): type = ST.equalSign, value = '=';
|
||||||
Node.comma(this.positionInMessage): type = ST.comma, value = ',';
|
Node.comma(this.positionInMessage): type = ST.comma, value = ',';
|
||||||
Node.string(this.positionInMessage, String this.value): type = ST.string;
|
Node.string(this.positionInMessage, String this.value): type = ST.string;
|
||||||
|
@ -914,10 +914,12 @@ abstract class ResidentHandlers {
|
|||||||
final Brightness? current = await flutterDevices.first!.vmService!.flutterBrightnessOverride(
|
final Brightness? current = await flutterDevices.first!.vmService!.flutterBrightnessOverride(
|
||||||
isolateId: views.first.uiIsolate!.id!,
|
isolateId: views.first.uiIsolate!.id!,
|
||||||
);
|
);
|
||||||
final Brightness next = switch (current) {
|
Brightness next;
|
||||||
Brightness.light => Brightness.dark,
|
if (current == Brightness.light) {
|
||||||
Brightness.dark || null => Brightness.light,
|
next = Brightness.dark;
|
||||||
};
|
} else {
|
||||||
|
next = Brightness.light;
|
||||||
|
}
|
||||||
for (final FlutterDevice? device in flutterDevices) {
|
for (final FlutterDevice? device in flutterDevices) {
|
||||||
final List<FlutterView> views = await device!.vmService!.getFlutterViews();
|
final List<FlutterView> views = await device!.vmService!.getFlutterViews();
|
||||||
for (final FlutterView view in views) {
|
for (final FlutterView view in views) {
|
||||||
|
@ -772,14 +772,15 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
return null;
|
return null;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
DeviceConnectionInterface? get deviceConnectionInterface {
|
DeviceConnectionInterface? get deviceConnectionInterface {
|
||||||
if ((argResults?.options.contains(FlutterOptions.kDeviceConnection) ?? false)
|
if ((argResults?.options.contains(FlutterOptions.kDeviceConnection) ?? false)
|
||||||
&& (argResults?.wasParsed(FlutterOptions.kDeviceConnection) ?? false)) {
|
&& (argResults?.wasParsed(FlutterOptions.kDeviceConnection) ?? false)) {
|
||||||
return switch (stringArg(FlutterOptions.kDeviceConnection)) {
|
final String? connectionType = stringArg(FlutterOptions.kDeviceConnection);
|
||||||
'attached' => DeviceConnectionInterface.attached,
|
if (connectionType == 'attached') {
|
||||||
'wireless' => DeviceConnectionInterface.wireless,
|
return DeviceConnectionInterface.attached;
|
||||||
_ => null,
|
} else if (connectionType == 'wireless') {
|
||||||
};
|
return DeviceConnectionInterface.wireless;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -290,11 +290,13 @@ class FakeDeviceManager implements DeviceManager {
|
|||||||
Device? getSingleEphemeralDevice(List<Device> devices) => null;
|
Device? getSingleEphemeralDevice(List<Device> devices) => null;
|
||||||
|
|
||||||
List<Device> filteredDevices(DeviceDiscoveryFilter? filter) {
|
List<Device> filteredDevices(DeviceDiscoveryFilter? filter) {
|
||||||
return switch (filter?.deviceConnectionInterface) {
|
if (filter?.deviceConnectionInterface == DeviceConnectionInterface.attached) {
|
||||||
DeviceConnectionInterface.attached => attachedDevices,
|
return attachedDevices;
|
||||||
DeviceConnectionInterface.wireless => wirelessDevices,
|
}
|
||||||
null => attachedDevices + wirelessDevices,
|
if (filter?.deviceConnectionInterface == DeviceConnectionInterface.wireless) {
|
||||||
};
|
return wirelessDevices;
|
||||||
|
}
|
||||||
|
return attachedDevices + wirelessDevices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user