knowa_sdk 2.0.0
knowa_sdk: ^2.0.0 copied to clipboard
Code push for Flutter on the stock Flutter SDK: ship a Dart fix to apps already installed, signed with your own key, with no forked engine.
example/main.dart
// A Flutter app wired to Knowa.
//
// In a real app `knowa init` generates the three constants below into
// lib/knowa_config.dart, from the keys it creates, and `knowa release` fills
// in knowaAppBridges while it builds. They are spelled out here so this file
// stands alone.
import 'package:flutter/material.dart';
import 'package:knowa_sdk/knowa_sdk.dart';
const knowaAppId = 'com.example.app';
const knowaTrustedPatchKeys = <String>['<your patch public key, base64>'];
const knowaRevocationKeys = <String>['<your revocation public key, base64>'];
const knowaAppBridges = <KBridge>[];
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Applies the patch already on the device, if any, and returns. The check
// for a newer one runs after the first frame and never delays startup.
final knowa = await Knowa.initialize(
const KnowaConfig(
appId: knowaAppId,
trustedKeys: knowaTrustedPatchKeys,
revocationKeys: knowaRevocationKeys,
source: PatchSource.server('https://knowa.knowalabs.com'),
bridges: knowaAppBridges,
),
);
debugPrint('Knowa: ${knowa.status}');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// After `knowa release`, a patch can replace this body: edit it and run
// `knowa patch`. An installed app downloads the patch on one launch and
// runs it from the next.
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: Center(child: Text('Shipped in the binary'))),
);
}
}