Skip to content

[RFW] Text widget fontWeight not applied in release mode #180223

Closed
flutter/packages
#11581

Description

@unwmun-canlab

Steps to reproduce

  1. Create a Flutter RFW project with the provided code sample below
  2. Use RFW's Text widget with fontWeight property in the style parameter (e.g., style: {fontWeight: "w700"})
  3. Run the app in debug mode - fontWeight appears correctly
  4. Build and run the app in release mode (flutter run --release or flutter build)
  5. Observe that the fontWeight is not applied to RFW Text widgets

Expected results

The fontWeight property of RFW Text widgets should be applied consistently in both debug and release modes, displaying the specified font weight (e.g., w700 appears bold, w400 appears normal).

Actual results

  • Debug mode: fontWeight is applied correctly - text appears with the specified font weight
  • Release mode: fontWeight is NOT applied - text appears with default font weight (w400) regardless of the specified value

Interestingly, when using a custom local widget (MText in the code sample) that manually handles fontWeight parsing, it works correctly in both debug and release modes. This suggests the issue is specific to RFW's built-in Text widget handling.

Code sample

Code sample
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

/// For clarity, this example uses the text representation of the sample remote
/// widget library, and parses it locally. To do this, [parseLibraryFile] is
/// used. In production, this is strongly discouraged since it is 10x slower
/// than using [decodeLibraryBlob] to parse the binary version of the format.
import 'package:rfw/formats.dart' show parseLibraryFile;

import 'package:rfw/rfw.dart';

void main() {
  runApp(const MaterialApp(home: Example()));
}

// The "#docregion" comment helps us keep this code in sync with the
// excerpt in the rfw package's README.md file.
//
// #docregion Example
class Example extends StatefulWidget {
  const Example({super.key});

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  final Runtime _runtime = Runtime();
  final DynamicContent _data = DynamicContent();

  @override
  void initState() {
    super.initState();
    _runtime.update(
      const LibraryName(<String>['core', 'widgets']),
      createCoreWidgets(),
    );
    _runtime.update(
      const LibraryName(<String>['core', 'material']),
      createMaterialWidgets(),
    );

    _update();
  }

  @override
  void reassemble() {
    // This function causes the Runtime to be updated any time the app is
    // hot reloaded, so that changes to _createLocalWidgets can be seen
    // during development. This function has no effect in production.
    super.reassemble();
    _update();
  }

  static WidgetLibrary _createLocalWidgets() {
    return LocalWidgetLibrary(<String, LocalWidgetBuilder>{
      'GreenBox': (BuildContext context, DataSource source) {
        return ColoredBox(
          color: const Color(0xFF002211),
          child: source.child(<Object>['child']),
        );
      },
      'Hello': (BuildContext context, DataSource source) {
        return Center(
          child: Text(
            'Hello, ${source.v<String>(<Object>["name"])}!',
            textDirection: TextDirection.ltr,
          ),
        );
      },
      'MText': (BuildContext context, DataSource source) {
        final String? fontWeightStr = source.v<String>(<Object>["fontWeight"]);
        FontWeight fontWeight = FontWeight.w400;
        if (fontWeightStr != null) {
          switch (fontWeightStr) {
            case "w100":
              fontWeight = FontWeight.w100;
              break;
            case "w200":
              fontWeight = FontWeight.w200;
              break;
            case "w300":
              fontWeight = FontWeight.w300;
              break;
            case "w400":
              fontWeight = FontWeight.w400;
              break;
            case "w500":
              fontWeight = FontWeight.w500;
              break;
            case "w600":
              fontWeight = FontWeight.w600;
              break;
            case "w700":
              fontWeight = FontWeight.w700;
              break;
            case "w800":
              fontWeight = FontWeight.w800;
              break;
            case "w900":
              fontWeight = FontWeight.w900;
              break;
          }
        }
        return Text(
          source.v<String>(<Object>["text"]) ?? '',
          textAlign: TextAlign.center,
          style: TextStyle(
              fontSize: source.v<double>(<Object>["fontSize"]) ?? 12.0,
              fontWeight: fontWeight),
        );
      },
    });
  }

  static const LibraryName localName = LibraryName(<String>['local']);
  static const LibraryName remoteName = LibraryName(<String>['remote']);

  void _update() {
    _runtime.update(localName, _createLocalWidgets());
    // Normally we would obtain the remote widget library in binary form from a
    // server, and decode it with [decodeLibraryBlob] rather than parsing the
    // text version using [parseLibraryFile]. However, to make it easier to
    // play with this sample, this uses the slower text format.
    _runtime.update(
      remoteName,
      parseLibraryFile('''
import core.widgets;
import core.material;
import local;

widget root = Scaffold(
  appBar: AppBar(title: Text(text: "Font Weight Demo")),
  body: Center(
    child: Column(
      mainAxisAlignment: "center",
      children: [
        Text(text: '(RFW) This is a test of the font weight. w700', textAlign: "center", style: {fontSize: 12.0, fontWeight: "w700"}),
        Text(text: '(RFW) This is a test of the font weight. w400', textAlign: "center", style: {fontSize: 12.0, fontWeight: "w400"}),
        MText(text: '(Local) This is a test of the font weight. w700', fontSize: 12.0, fontWeight: "w700"),
        MText(text: '(Local) This is a test of the font weight. w400', fontSize: 12.0, fontWeight: "w400"),
      ],
    ),
  ),
);

    '''),
    );
  }

  @override
  Widget build(BuildContext context) {
    return RemoteWidget(
      runtime: _runtime,
      data: _data,
      widget: const FullyQualifiedWidgetName(remoteName, 'root'),
      onEvent: (String name, DynamicMap arguments) {
        debugPrint('user triggered event "$name" with data: $arguments');
      },
    );
  }
}

// #enddocregion Example

Screenshots or Video

Screenshots / Video demonstration

Debug Mode (Working):

  • The first two lines (RFW Text) show correct font weights
  • The last two lines (Local MText) show correct font weights
  • w700 appears bold, w400 appears normal
Image

Release Mode (Not Working):

  • The first two lines (RFW Text) show incorrect font weights - both appear as w400
  • The last two lines (Local MText) show correct font weights
  • Only the local widget respects the fontWeight specification
Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.35.7, on macOS 15.6 24G84 darwin-arm64, locale ko-KR) [179ms]
    • Flutter version 3.35.7 on channel stable at /Users/unwmun/.asdf/installs/flutter/3.35.7-stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (9 weeks ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [714ms]
    • Android SDK at /Users/unwmun/Library/Android/sdk
    • Emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Users/unwmun/.asdf/installs/java/openjdk-17.0.2/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.2+8-86)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [553ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [5ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [5ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] Network resources [386ms]
    • All expected network resources are available.

Activity

  1. tirth-patel-nc commented on Dec 30, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions.

    stable : 3.38.5
    master : 3.40.0-1.0.pre-353
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    a: releaseChallenges faced when attempting to productionize an app
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    p: rfwRemote Flutter Widgets package
    a: typographyText rendering, possibly libtxt
    and removed
    in triagePresently being triaged by the triage team
    on Dec 30, 2025
  3. added
    P2Important issues not at the top of the work list
    on Jan 6, 2026
  4. 3 remaining items

  5. added 3 commits that reference this issue on Apr 29, 2026
    f5e544a
    96b86e1
    81f90e6
  6. added a commit that references this issue on May 17, 2026
    17d3122
  7. removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  8. added
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    and removed on Aug 26, 2026
  9. added a commit that references this issue on Sep 8, 2026
    6d39dc5
  10. added a commit that references this issue on Sep 17, 2026
    98d0412
  11. added a commit that references this issue on Sep 17, 2026
    9b86d89
  12. github-actions commented on Oct 1, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: releaseChallenges faced when attempting to productionize an appa: typographyText rendering, possibly libtxtfound in release: 3.38Found to occur in 3.38found in release: 3.40Found to occur in 3.40has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesp: rfwRemote Flutter Widgets packagepackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions