switch expressions: finale (#148711)
### fixes #136139 <br> <details open> <summary><b>getting sentimental in the PR description</b> (click to collapse)<br><br></summary> The past 7 months have been quite the journeyâI made some huge blunders and some huge accomplishmentsâa very fun time overall. I really appreciate the people who took the time to perform code review for my refactoring shenanigans: **christopherfujino**, **andrewkolos**, **LongCatIsLooong**, **gspencergoog**, **loic-sharma**, **Piinks**, **bernaferrari**, **bartekpacia**, **bleroux**, **kevmoo**, **rakudrama**, **XilaiZhang**, **QuncCccccc**, **MominRaza**, and **victorsanni**. And a huge shoutout to 2 individuals: - @justinmc, for offering to sponsor me for commit access (words could not describe my excitement) - @goderbauer, for being super duper proactive and consistent with code review <br> </details> This pull request makes 13 "switch statements â switch expressions" PRs in total, reducing the LOC in this repo by **1,974**! From now on, I'll make sure to request a test exemption for each refactoring PR ð
This commit is contained in:
@@ -377,22 +377,17 @@ class _CardsDemoState extends State<CardsDemo> {
|
||||
child: ListView(
|
||||
primary: true,
|
||||
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
|
||||
children: destinations.map<Widget>((TravelDestination destination) {
|
||||
Widget? child;
|
||||
switch (destination.type) {
|
||||
case CardDemoType.standard:
|
||||
child = TravelDestinationItem(destination: destination, shape: _shape);
|
||||
case CardDemoType.tappable:
|
||||
child = TappableTravelDestinationItem(destination: destination, shape: _shape);
|
||||
case CardDemoType.selectable:
|
||||
child = SelectableTravelDestinationItem(destination: destination, shape: _shape);
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
child: child,
|
||||
);
|
||||
}).toList(),
|
||||
children: <Widget>[
|
||||
for (final TravelDestination destination in destinations)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: switch (destination.type) {
|
||||
CardDemoType.standard => TravelDestinationItem(destination: destination, shape: _shape),
|
||||
CardDemoType.tappable => TappableTravelDestinationItem(destination: destination, shape: _shape),
|
||||
CardDemoType.selectable => SelectableTravelDestinationItem(destination: destination, shape: _shape),
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -100,20 +100,13 @@ class CutCornersBorder extends OutlineInputBorder {
|
||||
if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) {
|
||||
canvas.drawPath(_notchedCornerPath(outer.middleRect), paint);
|
||||
} else {
|
||||
final double? extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
|
||||
switch (textDirection) {
|
||||
case TextDirection.rtl: {
|
||||
final Path path = _notchedCornerPath(outer.middleRect, gapStart + gapPadding - extent!, extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
case TextDirection.ltr: {
|
||||
final Path path = _notchedCornerPath(outer.middleRect, gapStart - gapPadding, extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
case null:
|
||||
break;
|
||||
final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage)!;
|
||||
if (textDirection != null) {
|
||||
final double start = switch (textDirection) {
|
||||
TextDirection.rtl => gapStart + gapPadding - extent,
|
||||
TextDirection.ltr => gapStart - gapPadding,
|
||||
};
|
||||
canvas.drawPath(_notchedCornerPath(outer.middleRect, start, extent), paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user