Skip to content

MinimumTextContrastGuideline fails when button/label contrast appears to be OK #22044

@HansMuller

Description

@HansMuller

I've introduced some significant changes to ButtonTheme et al. in #22013.

With these changes, three RaisedButton contrast tests from examples/flutter_gallery/test/accessibility_test.dart fail.

The buttons appear to be rendered correctly and with sufficient contrast. The tests computed foreground and background colors aren't what I'd expect, they should be background: 0xff0175c2 (see examples/flutter_gallery/lib/gallery/themes.dart primaryColor in buildLightTheme), foreground: white.

show_bottom_sheet

// 'modal_bottom_sheet_demo'
The following TestFailure object was thrown running a test:
  Expected: Text contrast should follow WCAG guidelines
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#786(Rect.fromLTRB(265.0, 304.0, 535.0, 352.0), actions: [tap], flags:
   [isButton, hasEnabledState, isEnabled], label: "SHOW BOTTOM SHEET", textDirection: ltr):
          Expected contrast ratio of at least 4.5 but found 2.65 for a font size of 14.0. The
          computed foreground color was: Color(0xff6200ee), The computed background color was:
          Color(0xff0d0020)
          See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html

// 'persistent_bottom_sheet_demo'
The following TestFailure object was thrown running a test:
  Expected: Text contrast should follow WCAG guidelines
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#893(Rect.fromLTRB(279.0, 168.0, 521.0, 216.0), actions: [tap], flags:
   [isButton, hasEnabledState, isEnabled], label: "SHOW A SNACKBAR", textDirection: ltr):
          Expected contrast ratio of at least 4.5 but found 2.65 for a font size of 14.0. The
          computed foreground color was: Color(0xff6200ee), The computed background color was:
          Color(0xff0d0020)
          See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html

// 'snack_bar_demo'
The following TestFailure object was thrown running a test:
  Expected: Text contrast should follow WCAG guidelines
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#786(Rect.fromLTRB(265.0, 304.0, 535.0, 352.0), actions: [tap], flags:
   [isButton, hasEnabledState, isEnabled], label: "SHOW BOTTOM SHEET", textDirection: ltr):
          Expected contrast ratio of at least 4.5 but found 2.65 for a font size of 14.0. The
          computed foreground color was: Color(0xff6200ee), The computed background color was:
          Color(0xff0d0020)
          See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions