diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index eb7fb2c8c56..7b6c5ebdc77 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -215,27 +215,16 @@ class Typography with Diagnosticable { TextTheme tall, ) { assert(platform != null || (black != null && white != null)); - switch (platform) { - case TargetPlatform.iOS: - black ??= blackCupertino; - white ??= whiteCupertino; - case TargetPlatform.android: - case TargetPlatform.fuchsia: - black ??= blackMountainView; - white ??= whiteMountainView; - case TargetPlatform.windows: - black ??= blackRedmond; - white ??= whiteRedmond; - case TargetPlatform.macOS: - black ??= blackRedwoodCity; - white ??= whiteRedwoodCity; - case TargetPlatform.linux: - black ??= blackHelsinki; - white ??= whiteHelsinki; - case null: - break; - } - return Typography._(black!, white!, englishLike, dense, tall); + final (TextTheme blackResolved, TextTheme whiteResolved) = switch (platform) { + TargetPlatform.iOS => (black ?? blackCupertino, white ?? whiteCupertino), + TargetPlatform.android || + TargetPlatform.fuchsia => (black ?? blackMountainView, white ?? whiteMountainView), + TargetPlatform.windows => (black ?? blackRedmond, white ?? whiteRedmond), + TargetPlatform.macOS => (black ?? blackRedwoodCity, white ?? whiteRedwoodCity), + TargetPlatform.linux => (black ?? blackHelsinki, white ?? whiteHelsinki), + null => (black!, white!), + }; + return Typography._(blackResolved, whiteResolved, englishLike, dense, tall); } const Typography._(this.black, this.white, this.englishLike, this.dense, this.tall);