diff --git a/packages/material_ui/lib/src/typography.dart b/packages/material_ui/lib/src/typography.dart index aef5de04708..2918880e4e9 100644 --- a/packages/material_ui/lib/src/typography.dart +++ b/packages/material_ui/lib/src/typography.dart @@ -164,52 +164,21 @@ class Typography with Diagnosticable { /// Creates a typography instance using Material Design 3 2021 defaults. /// - /// Text colors are derived from [colorScheme]. For a light [colorScheme], - /// every style in the resulting [Typography.black] uses - /// [ColorScheme.onSurface] and every style in [Typography.white] uses - /// [ColorScheme.surface]. For a dark [colorScheme], these are reversed. The - /// same colors are used for [TextStyle.decorationColor]. - /// - /// The default values for [black] and [white] depend on [platform]: - /// [blackCupertino] and [whiteCupertino] on iOS, [blackRedwoodCity] and - /// [whiteRedwoodCity] on macOS, [blackRedmond] and [whiteRedmond] on - /// Windows, [blackHelsinki] and [whiteHelsinki] on Linux, and - /// [blackMountainView] and [whiteMountainView] otherwise. If [platform] is - /// null then both [black] and [white] must be specified. + /// If [platform] is [TargetPlatform.iOS] or [TargetPlatform.macOS], the + /// default values for [black] and [white] are [blackCupertino] and + /// [whiteCupertino] respectively. Otherwise they are [blackMountainView] and + /// [whiteMountainView]. If [platform] is null then both [black] and [white] + /// must be specified. /// /// The default values for [englishLike], [dense], and [tall] are /// [englishLike2021], [dense2021], and [tall2021]. /// - /// The [black] and [white] parameters are deprecated. Only their non-color - /// properties (such as font family) are used. Any [TextStyle.color] or - /// [TextStyle.decorationColor] they specify is replaced with a color from - /// [colorScheme] as described above. To customize the text theme's colors, - /// call [copyWith] on the result: - /// - /// ```dart - /// final Typography base = Typography.material2021(colorScheme: colorScheme); - /// final Typography typography = base.copyWith( - /// black: base.black.merge(myBlack), - /// white: base.white.merge(myWhite), - /// ); - /// ``` - /// /// See also: /// * factory Typography.material2021({ TargetPlatform? platform = TargetPlatform.android, ColorScheme colorScheme = const ColorScheme.light(), - @Deprecated( - 'Text colors are derived from colorScheme, so colors in this text theme are ignored. ' - 'Use copyWith on the result to customize the black text theme. ' - 'This feature was deprecated after material_ui v1.8.0.', - ) TextTheme? black, - @Deprecated( - 'Text colors are derived from colorScheme, so colors in this text theme are ignored. ' - 'Use copyWith on the result to customize the white text theme. ' - 'This feature was deprecated after material_ui v1.8.0.', - ) TextTheme? white, TextTheme? englishLike, TextTheme? dense, diff --git a/packages/material_ui/pending_changelogs/change_2026_10_26_typography_2021_deprecate_black_white.yaml b/packages/material_ui/pending_changelogs/change_2026_10_26_typography_2021_deprecate_black_white.yaml deleted file mode 100644 index aeade149e5e..00000000000 --- a/packages/material_ui/pending_changelogs/change_2026_10_26_typography_2021_deprecate_black_white.yaml +++ /dev/null @@ -1,3 +0,0 @@ -changelog: | - - Deprecates the `black` and `white` parameters of `Typography.material2021`, and documents that their colors are replaced with colors from the `colorScheme`. -version: minor diff --git a/packages/material_ui/test/typography_test.dart b/packages/material_ui/test/typography_test.dart index 4e87b38ea05..1d7a4120609 100644 --- a/packages/material_ui/test/typography_test.dart +++ b/packages/material_ui/test/typography_test.dart @@ -445,47 +445,6 @@ void main() { expect(textTheme.labelSmall!.color, light); }); - group('Typography.material2021 deprecated black and white', () { - const lightScheme = ColorScheme.light(onSurface: Color(0xFF000001), surface: Color(0xFFFFFFF1)); - const custom = TextTheme( - bodyMedium: TextStyle( - fontFamily: 'Custom', - color: Color(0xFFFF0000), - decorationColor: Color(0xFF00FF00), - ), - ); - - test('keep non-color properties but replace colors from the color scheme', () { - final typography = Typography.material2021( - colorScheme: lightScheme, - // ignore: deprecated_member_use_from_same_package - black: custom, - // ignore: deprecated_member_use_from_same_package - white: custom, - ); - expect(typography.black.bodyMedium!.fontFamily, 'Custom'); - expect(typography.black.bodyMedium!.color, lightScheme.onSurface); - expect(typography.black.bodyMedium!.decorationColor, lightScheme.onSurface); - expect(typography.white.bodyMedium!.fontFamily, 'Custom'); - expect(typography.white.bodyMedium!.color, lightScheme.surface); - expect(typography.white.bodyMedium!.decorationColor, lightScheme.surface); - }); - - test('copyWith can be used to customize colors instead', () { - final base = Typography.material2021(colorScheme: lightScheme); - final Typography typography = base.copyWith( - black: base.black.merge(custom), - white: base.white.merge(custom), - ); - expect(typography.black.bodyMedium!.fontFamily, 'Custom'); - expect(typography.black.bodyMedium!.color, const Color(0xFFFF0000)); - expect(typography.white.bodyMedium!.color, const Color(0xFFFF0000)); - // Styles that are not overridden keep the generated values. - expect(typography.black.bodyLarge!.fontFamily, 'Roboto'); - expect(typography.black.bodyLarge!.color, lightScheme.onSurface); - }); - }); - test('Typography.material2021 colors black and white text themes from the colorScheme', () { const lightScheme = ColorScheme.light(onSurface: Color(0xFF000001), surface: Color(0xFFFFFFF1)); const darkScheme = ColorScheme.dark(onSurface: Color(0xFFFFFFF2), surface: Color(0xFF000002));