Skip to main content

valence 0.4.0-beta.0 copy "valence: ^0.4.0-beta.0" to clipboard
valence: ^0.4.0-beta.0 copied to clipboard

The Flutter host runtime for Valence. A signed over-the-air web bundle on a loopback server, an offline-first SQLite store with incremental sync, and a typed bridge generated from one schema.

example/lib/main.dart

// The whole host, for an app that adds one native method of its own.
//
// Everything the spec calls the host — the loopback server, the updater and its rollback, the SQLite
// store, sync, the bridge trust boundary, the WebView with its navigation lock and back gesture — is in
// the `valence` package. This file is the app-specific part, and that is all of it.
import 'package:flutter/material.dart';
import 'package:valence/valence.dart';
import 'package:valence_example_haptics/haptics.dart';

import 'valence/bridge.g.dart';
import 'valence/config.g.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final valence = await Valence.open(valenceConfig, hostBuild: 1);
  final handlers = AppHandlers(valence);
  runApp(
    MaterialApp(
      title: 'Valence example',
      debugShowCheckedModeBanner: false,
      home: ValenceApp(
        valence: valence,
        dispatch: (raw, nonce) => bridgeDispatch(handlers, raw, nonce: nonce),
      ),
    ),
  );
}

/// This app's bridge methods.
///
/// `ValenceBuiltins` is generated, and already implements `app.*`, `data.*`, `prefs.*`, `sync.*`,
/// `open.external` and `bundle.*` by delegating to the runtime. Only what is genuinely native to this app
/// is registered here — the separate haptics plugin supplies the native tap.
class AppHandlers extends ValenceBuiltins implements BridgeHandlers {
  AppHandlers(super.valence) : super(plugins: [const HapticsPlugin()]);
}
0
likes
0
points
--
downloads

Documentation

Documentation

Publisher

verified publishergetvalence.dev

Weekly Downloads

The Flutter host runtime for Valence. A signed over-the-air web bundle on a loopback server, an offline-first SQLite store with incremental sync, and a typed bridge generated from one schema.

Homepage
Repository (GitHub)
View/report issues

Topics

#webview #ota #offline-first #sqlite #code-push

License

unknown (license)

Dependencies

app_badge_plus, app_links, connectivity_plus, crypto, cryptography, device_info_plus, flutter, flutter_local_notifications, flutter_secure_storage, http, path_provider, path_provider_android, permission_handler, share_plus, sqflite, timezone, url_launcher, webview_flutter, webview_flutter_android

More

Packages that depend on valence