Skip to content

Conversation

@shindonghwi
Copy link
Contributor

@shindonghwi shindonghwi commented Dec 15, 2025

Problem

When you change textAlign on a RenderParagraph, the parent widget doesn't know the layout changed.

Example: If you use LayoutBuilder to position elements based on text alignment, changing from TextAlign.left to TextAlign.right won't trigger a rebuild - even though the text moved.

Cause

The textAlign setter was calling markNeedsPaint() (just repaint) instead of markNeedsLayout() (recalculate layout).

Fix

One line change: markNeedsPaint()markNeedsLayout()

This matches how other setters like textDirection and softWrap already work.

Fixes

#140756

Pre-launch Checklist

The textAlign setter was only calling markNeedsPaint(), which meant
that parent widgets using LayoutBuilder would not be notified when
text alignment changed. This fix changes it to call markNeedsLayout()
instead, consistent with other setters like textDirection and softWrap
that affect layout.

Fixes flutter#140756
@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Dec 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly changes the textAlign setter in RenderParagraph to call markNeedsLayout() instead of markNeedsPaint(). This change ensures that modifying the text alignment properly invalidates the layout, which is consistent with other layout-related properties in the class. The test for this behavior has also been updated to reflect the fix, now correctly asserting that debugNeedsLayout is true after the property change and using pumpFrame() to process the layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant