-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
I'm writing a dart fix that migrates a constructor argument from a double? to a TextScaler?, the migrated code is hard to read in some cases.
Original Code:
Text(textScaleFactor: scaleFactor) where scaleFactor is an expression that can either be a double?, double, or null.
Desired migrated code:
if scaleFactor's static type is double? => Text(textScaler: switch (scaleFactor) { null => null, final factor => TextScaler.linear(factor), })
if scaleFactor's static type is double => Text(textScaler: TextScaler.linear(scaleFactor)
if scaleFactor's static type is null => Text()
Current migrated code:
Text(textScaler: switch (scaleFactor) { null => null, final factor => TextScaler.linear(factor), })When scaleFactor is a double the current code is a lot harder to read than necessary, e.g.:
Text(textScaler: switch (2.0) { null => null, final factor => TextScaler.linear(factor), })Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug