Skip to content

[RFW] Unable to use customizedErrorWidget.builder in RFW #144960

@peixinli

Description

@peixinli

Steps to reproduce

Override the error widget builder with ErrorWidget.builder.

Expected results

RFW should render the override error widget.

Actual results

RFW still renders the default error widget.

Code sample

Code sample
void main() {
  ErrorWidget.builder = (FlutterErrorDetails details) {
    // In release builds, show a yellow-on-blue message instead:
    return Container(
      alignment: Alignment.center,
      child: Text(
        'Error!\n${details.exception}',
        style: const TextStyle(color: Colors.yellow),
        textAlign: TextAlign.center,
        textDirection: TextDirection.ltr,
      ),
    );
  };
  runApp(const 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();

  static final RemoteWidgetLibrary _remoteWidgets = parseLibraryFile('''
    import core.widgets;
    widget root = Container(
      color: 0xFF002211,
      child: Center(
        child: Random(text: ["Hello, ", data.name.greet, "!"], textDirection: "ltr"),
      ),
    );
  ''');

  static const LibraryName coreName = LibraryName(<String>['core', 'widgets']);
  static const LibraryName mainName = LibraryName(<String>['main']);

  @override
  void initState() {
    super.initState();
    _runtime.update(coreName, createCoreWidgets());
    _runtime.update(mainName, _remoteWidgets);
    _data.update('greet', <String, Object>{'name': 'World'});
  }

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

Screenshots or Video

Screenshots Screenshot 2024-03-11 at 2 45 42 PM

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.20Found to occur in 3.20found in release: 3.21Found to occur in 3.21has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: rfwRemote Flutter Widgets packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions