Repository navigation
Commit 9b86d89
authored
[rfw] Fix fontWeight not applied in release mode (flutter#11581)
Fixes the `fontWeight` property of RFW `TextStyle` (and `StrutStyle`) not being applied in release mode for `Text` widgets.
Fixes flutter#180223
## Root cause
`ArgumentDecoders.textStyle` (and `strutStyle`) decoded `fontWeight` using `enumValue(FontWeight.values, ...)`, which matched the input string against `FontWeight.value.toString().split('.').last`. `FontWeight` is not a real Dart `enum`; it is a hand-crafted class with `static const` members. In AOT/release builds, `toString()` for such classes is not guaranteed to return the same human-readable name (tree-shaking can strip debug labels), so all matches silently fail and `null` is returned, causing Flutter to fall back to the default weight (`w400`).
## Fix
Added a new `ArgumentDecoders.fontWeight` static 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()`. Updated both `textStyle` and `strutStyle` to use this new decoder.
## Pre-Review Checklist1 parent 34c0119 commit 9b86d89
4 files changed
Lines changed: 154 additions & 6 deletions
File tree
- packages/rfw
- lib/src/flutter
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
635 | 675 | | |
636 | 676 | | |
637 | 677 | | |
| |||
1276 | 1316 | | |
1277 | 1317 | | |
1278 | 1318 | | |
1279 | | - | |
| 1319 | + | |
1280 | 1320 | | |
1281 | 1321 | | |
1282 | 1322 | | |
| |||
1289 | 1329 | | |
1290 | 1330 | | |
1291 | 1331 | | |
1292 | | - | |
| 1332 | + | |
1293 | 1333 | | |
1294 | 1334 | | |
1295 | 1335 | | |
| |||
1350 | 1390 | | |
1351 | 1391 | | |
1352 | 1392 | | |
1353 | | - | |
| 1393 | + | |
1354 | 1394 | | |
1355 | 1395 | | |
1356 | 1396 | | |
| |||
1369 | 1409 | | |
1370 | 1410 | | |
1371 | 1411 | | |
1372 | | - | |
| 1412 | + | |
1373 | 1413 | | |
1374 | 1414 | | |
1375 | 1415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
554 | 661 | | |
0 commit comments