Skip to content

[rfw] Fix fontWeight not applied in release mode#11581

Open
iam-abhijha wants to merge 1 commit intoflutter:mainfrom
iam-abhijha:fix/rfw-font-weight-release-mode
Open

[rfw] Fix fontWeight not applied in release mode#11581
iam-abhijha wants to merge 1 commit intoflutter:mainfrom
iam-abhijha:fix/rfw-font-weight-release-mode

Conversation

@iam-abhijha
Copy link
Copy Markdown

@iam-abhijha iam-abhijha commented Apr 25, 2026

Fixes flutter/flutter#180223

When using the RFW Text widget with a fontWeight in the style, the weight applies correctly in debug mode but is completely ignored in release mode — everything renders as w400 regardless of what you specify.

The root cause is in ArgumentDecoders.textStyle (and strutStyle), where fontWeight was being decoded using enumValue(FontWeight.values, ...). The enumValue method works by calling .toString().split('.').last on each value and matching against the input string. This works fine in debug, but FontWeight is not a real Dart enum — it's a hand-crafted class with static const members. In release mode, tree-shaking can break .toString() for these kinds of classes, so all matches silently fail and return null, which Flutter then renders as the default weight.

The fix adds a dedicated fontWeight static method to ArgumentDecoders that uses an explicit switch on the raw string/integer value instead of relying on toString(). This also adds support for integer values (700) alongside the existing string format ("w700"), and adds "normal" and "bold" as convenient aliases.

Changes:

  • Added ArgumentDecoders.fontWeight static method with explicit string and integer matching
  • Updated textStyle and strutStyle to use the new method instead of enumValue
  • Fixed missing ...key spread for textBaseline and overflow in textStyle
  • Fixed missing ...key spread for textDirection in the shader decoder
  • Added tests covering all weight values (w100–w900), aliases (normal, bold), integer format, unknown values, and missing keys — for both textStyle and strutStyle

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 25, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the p: rfw Remote Flutter Widgets label Apr 25, 2026
Copy link
Copy Markdown

@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 introduces a dedicated fontWeight decoder to handle FontWeight values as strings or integers, ensuring stability in release mode. It updates strutStyle and textStyle to utilize this new decoder and includes comprehensive tests. Feedback identifies several instances where absolute keys are used for property lookups—specifically textDirection in the sweep shader, and textBaseline and overflow in textStyle—instead of relative keys, which prevents correct resolution when these structures are nested.

Comment thread packages/rfw/lib/src/flutter/argument_decoders.dart Outdated
Comment thread packages/rfw/lib/src/flutter/argument_decoders.dart Outdated
Comment thread packages/rfw/lib/src/flutter/argument_decoders.dart Outdated
@iam-abhijha iam-abhijha force-pushed the fix/rfw-font-weight-release-mode branch from 26f029c to d9c573b Compare April 25, 2026 17:03
@iam-abhijha iam-abhijha force-pushed the fix/rfw-font-weight-release-mode branch from d9c573b to a8bd4b5 Compare April 25, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: rfw Remote Flutter Widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFW] Text widget fontWeight not applied in release mode

1 participant