knowa_flutter_bindings 2.2.0
knowa_flutter_bindings: ^2.2.0 copied to clipboard
The Flutter classes a Knowa code-push patch can use, bound for Knowa's patch runtime. You do not depend on it directly: knowa_sdk does.
example/example.dart
// Builds a widget from a patch using the Flutter bindings.
//
// Patches are normally compiled from Dart source by the Knowa CLI, and
// knowa_sdk registers these bindings for you. This example builds the
// compiled form of the following patch by hand:
//
// @KnowaOverride('home.title')
// Widget title() => const Text('Hello from a patch');
import 'package:flutter/material.dart';
import 'package:knowa_flutter_bindings/knowa_flutter_bindings.dart';
import 'package:knowa_kernel/knowa_kernel.dart';
void main() {
final interpreter = KInterpreter(
const KModule(
functions: {
'title': KFunction(
name: 'title',
params: [],
frameSize: 0,
body: KReturn(
KConstruct('Text', '', KArgs([KLiteral('Hello from a patch')])),
),
),
},
classes: {},
overrides: {'home.title': 'title'},
),
bridges: knowaFlutterBridges,
);
final title = interpreter.callOverride('home.title') as Widget;
runApp(MaterialApp(home: Scaffold(body: Center(child: title))));
}