Skip to content
pubscout

rfw

2.0.0, released 4 weeks ago by flutter.dev

Renders declarative widget description files at runtime for Remote Flutter Widgets.

WASM-readyUses material_ui
$ flutter pub add rfw
Source repository

What it does

Allows Flutter apps to render remote widget descriptions obtained dynamically at runtime. It combines a runtime engine, configuration data, and local widget libraries to build arbitrary widget trees.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to display dynamic UI or search results that could not be known when the app was created.
  • You want to build database frontends with bespoke UIs for editing different types of objects.

Skip it when

  • You want to create completely new custom widgets involving page transitions, drag and drop, or custom painters.
  • You want to update the core application look, feel, or navigation which should be shipped via normal updates.

Strengths

  • Keeps formats and supported widget sets backwards compatible.
  • Supports both text and binary formats for transporting remote widget libraries and data.
  • Can be used on the server or command-line for parts dealing only with formats.

Weaknesses

  • Cannot create complex custom widgets or custom painters from the remote descriptions.
  • Potential theoretical performance limitations depending on implementation scale.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

No special native permissions or build_runner steps required; simply include the package and initialize Runtime and DynamicContent.

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: Text(text: ["Hello, ", data.greet.name, "!"], 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');
      },
    );
  }
}

Works with

Packages commonly used together with rfw: ones it builds on, ones built on it, and its own family.