Created
November 9, 2025 13:38
-
-
Save fredgrott/cd82ca0022ec6586dfbe693a8315252c to your computer and use it in GitHub Desktop.
SDK typograhy calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| factory Typography.material2021({ | |
| TargetPlatform? platform = TargetPlatform.android, | |
| ColorScheme colorScheme = const ColorScheme.light(), | |
| TextTheme? black, | |
| TextTheme? white, | |
| TextTheme? englishLike, | |
| TextTheme? dense, | |
| TextTheme? tall, | |
| }) { | |
| assert(platform != null || (black != null && white != null)); | |
| final Typography base = Typography._withPlatform( | |
| platform, | |
| black, | |
| white, | |
| englishLike ?? englishLike2021, | |
| dense ?? dense2021, | |
| tall ?? tall2021, | |
| ); | |
| // Ensure they are all uniformly dark or light, with | |
| // no color variation based on style as it was in previous | |
| // versions of Material Design. | |
| final Color dark = colorScheme.brightness == Brightness.light | |
| ? colorScheme.onSurface | |
| : colorScheme.surface; | |
| final Color light = colorScheme.brightness == Brightness.light | |
| ? colorScheme.surface | |
| : colorScheme.onSurface; | |
| return base.copyWith( | |
| black: base.black.apply(displayColor: dark, bodyColor: dark, decorationColor: dark), | |
| white: base.white.apply(displayColor: light, bodyColor: light, decorationColor: light), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment