Use EvalWidget for Dynamic UI and Server-Driven UI
masterThe EvalWidget is a versatile widget that automatically switches behavior based on the build mode:
- Debug Mode: It dynamically compiles the provided Dart code into EVC bytecode, saves it to the
assetPath, and runs it. This allows for hot-reloading during development. - Release Mode: It ignores the provided Dart code and attempts to load EVC bytecode from the
assetPathor a networkuri.
Use EvalWidget when you want a seamless transition from local development (writing Dart) to production (loading pre-compiled EVC).
return EvalWidget(
packages: {
'example': {
'main.dart': '''
import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
MyWidget(this.name);
final String name;
@override
Widget build(BuildContext context) => Text(name);
}
''',
},
},
assetPath: 'assets/program.evc',
library: 'package:example/main.dart',
function: 'MyWidget.',
args: [$String('Example name')]
);