[rfw] Fix fontWeight not applied in release mode#11581
[rfw] Fix fontWeight not applied in release mode#11581iam-abhijha wants to merge 1 commit intoflutter:mainfrom
Conversation
|
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. |
There was a problem hiding this comment.
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.
26f029c to
d9c573b
Compare
d9c573b to
a8bd4b5
Compare
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:
ArgumentDecoders.fontWeightstatic method with explicit string and integer matchingtextStyleandstrutStyleto use the new method instead ofenumValue...keyspread fortextBaselineandoverflowintextStyle...keyspread fortextDirectionin the shader decodertextStyleandstrutStyle