themeTest function

  1. @isTest
void themeTest(
  1. dynamic description,
  2. ThemeData themeData, {
  3. ThemeAccessibilityLevel accessibilityLevel = ThemeAccessibilityLevel.normal,
  4. dynamic tags,
})

Creates a new theme test case with the given description.

Scans through given themeData, looking for insufficient contrast values between text and background colors.

Example error message:

Contrast ratio of primaryColorLight (Color(0xffbbdefb))
and primaryTextTheme.bodyLarge?.color (Color(0xffffffff)) is 1.40:1,
which is not sufficient for specified ThemeAccessibilityLevel.normal.
ThemeAccessibilityLevel.normal's lowest acceptable contrast ratio is 4.5:1.

If tags is passed, it declares user-defined tags that are applied to the test. These tags can be used to select or skip the test on the command line, or to do bulk test configuration. All tags should be declared in the package configuration file. The parameter can be an Iterable of tag names, or a String representing a single tag.

Implementation

@isTest
void themeTest(
  dynamic description,
  ThemeData themeData, {
  ThemeAccessibilityLevel accessibilityLevel = ThemeAccessibilityLevel.normal,
  dynamic tags,
}) {
  test.test(
    description,
    () => runThemeTest(themeData, accessibilityLevel: accessibilityLevel),
    tags: tags,
  );
}