Skip to main content

knowa_sdk 2.0.0 copy "knowa_sdk: ^2.0.0" to clipboard
knowa_sdk: ^2.0.0 copied to clipboard

unlisted

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'))),
    );
  }
}
0
likes
0
points
538
downloads

Publisher

verified publisherknowalabs.com

Weekly Downloads

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.

Homepage

Topics

#code-push #ota-updates #hotfix #flutter

License

unknown (license)

Dependencies

cryptography, flutter, http, knowa_flutter_bindings, knowa_kernel, knowa_patch_format, package_info_plus, path_provider

More

Packages that depend on knowa_sdk