Skip to content

[material_ui] SnackBar action overflow calculation does not account for MediaQuery textScaler #192232

Closed
flutter/packages
#12737

Description

@matasb-google

Problem Description

When calculating whether a SnackBar action and icon overflow the available snackBarWidth (willOverflowAction in _SnackBarState), actionTextPainter is created without passing MediaQuery.textScalerOf(context):

final actionTextPainter = TextPainter(
  text: TextSpan(
    text: widget.action?.label ?? '',
    style: Theme.of(context).textTheme.labelLarge,
  ),
  maxLines: 1,
  textDirection: TextDirection.ltr,
)..layout();

As a result:

  1. When a user has accessibility / text scaling enabled, the rendered action button scales up, but actionTextPainter computes the unscaled width (scale 1.0).
  2. willOverflowAction evaluates to false when it should be true, causing action buttons to overflow or become cramped/truncated on single-line layouts instead of properly wrapping into a multi-line layout.
  3. Additionally, in the multi-line layout, an unnecessary SizedBox(width: snackBarWidth * 0.4) was being added to the content row, leaving 40% blank space on the right of multi-line content.

Proposal

  • Pass textScaler: MediaQuery.textScalerOf(context) to actionTextPainter in _SnackBarState.
  • Remove the snackBarWidth * 0.4 sized box when willOverflowAction is true.

Related / original PR: #181959

Activity

  1. added
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    in triagePresently being triaged by the triage team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Sep 3, 2026
  2. mbcorona commented on Sep 3, 2026

    @mbcorona
    Member

    Hi @matasb-google , thanks for reporting this and linking a PR.
    Im routing to the design team as a proposal to evaluate.

  3. added
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    on Sep 3, 2026
  4. added
    P3Issues that are less important to the Flutter project
    triaged-designTriaged by Design Languages team
    on Sep 8, 2026
  5. github-actions commented on Oct 24, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions