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
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.
- material_uirfw depends on itOfficial Flutter Material UI library implementing Google’s Material Design system.
- go_routerSame familyDeclarative routing package for Flutter based on Navigation 2 supporting deep links and URL-based navigation.
- google_fontsSame familyFlutter package to load Google Fonts at runtime or bundle them as assets
- animationsSame familyFancy pre-built animations that can easily be integrated into any Flutter application.
- koolbase_flutterBuilt on rfwFlutter SDK for Koolbase BaaS providing auth, database, storage, realtime and OTA updates.