Skip to content

Commit 1944db2

Browse files
committed
[rfw] Fix fontWeight not applied in release mode
FontWeight is not a real Dart enum; it is a hand-crafted class with static const members. The previous implementation decoded fontWeight via enumValue(), which matched strings against FontWeight.value.toString(). In AOT/release builds this is not guaranteed to be stable, so matches silently failed and fontWeight defaulted to null (rendered as w400). Add a dedicated ArgumentDecoders.fontWeight() method that maps strings ("w100"–"w900", "normal", "bold") and integers (100–900) to the correct FontWeight constant using an explicit switch, without relying on toString(). Update textStyle and strutStyle to use it. Also fix three pre-existing bugs where absolute keys were used instead of relative keys: - textDirection in the sweep shader decoder - textBaseline in textStyle - overflow in textStyle Fixes flutter/flutter#180223 Made-with: Cursor
1 parent 73f4d49 commit 1944db2

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/rfw/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.4
2+
3+
* Fixes `fontWeight` not being applied in release mode for `Text` and `StrutStyle` widgets.
4+
15
## 1.1.3
26

37
* Fixes dartdoc comments that accidentally used HTML.

packages/rfw/lib/src/flutter/argument_decoders.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ class ArgumentDecoders {
12831283
case 'sweep':
12841284
return gradient(source, key)!.createShader(
12851285
rect(source, [...key, 'rect']) ?? Rect.zero,
1286-
textDirection: enumValue<TextDirection>(TextDirection.values, source, ['textDirection']) ?? TextDirection.ltr,
1286+
textDirection: enumValue<TextDirection>(TextDirection.values, source, [...key, 'textDirection']) ?? TextDirection.ltr,
12871287
);
12881288
default:
12891289
final ArgumentDecoder<Shader?>? decoder = shaderDecoders[type];
@@ -1413,7 +1413,7 @@ class ArgumentDecoders {
14131413
fontStyle: enumValue<FontStyle>(FontStyle.values, source, [...key, 'fontStyle']),
14141414
letterSpacing: source.v<double>([...key, 'letterSpacing']),
14151415
wordSpacing: source.v<double>([...key, 'wordSpacing']),
1416-
textBaseline: enumValue<TextBaseline>(TextBaseline.values, source, ['textBaseline']),
1416+
textBaseline: enumValue<TextBaseline>(TextBaseline.values, source, [...key, 'textBaseline']),
14171417
height: source.v<double>([...key, 'height']),
14181418
leadingDistribution: enumValue<TextLeadingDistribution>(TextLeadingDistribution.values, source, [...key, 'leadingDistribution']),
14191419
locale: locale(source, [...key, 'locale']),
@@ -1427,7 +1427,7 @@ class ArgumentDecoders {
14271427
decorationThickness: source.v<double>([...key, 'decorationThickness']),
14281428
fontFamily: source.v<String>([...key, 'fontFamily']),
14291429
fontFamilyFallback: list<String>(source, [...key, 'fontFamilyFallback'], string),
1430-
overflow: enumValue<TextOverflow>(TextOverflow.values, source, ['overflow']),
1430+
overflow: enumValue<TextOverflow>(TextOverflow.values, source, [...key, 'overflow']),
14311431
);
14321432
}
14331433

packages/rfw/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: rfw
22
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
33
repository: https://github.com/flutter/packages/tree/main/packages/rfw
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
5-
version: 1.1.3
5+
version: 1.1.4
66

77
environment:
88
sdk: ^3.9.0

0 commit comments

Comments
 (0)