Skip to main content

passnote_flutter 1.1.0 copy "passnote_flutter: ^1.1.0" to clipboard
passnote_flutter: ^1.1.0 copied to clipboard

Passnote for Flutter: the full library plus keychain key store, collection notifier, and batteries-included setup.

example/passnote_flutter_example.dart

// A minimal Flutter app on Passnote: open a database, watch a collection,
// add items. The complete tutorial app lives in the repository under
// `examples/quickstart/`.
import 'package:passnote_flutter/passnote_flutter.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final passnote = await passnoteBuilder(appId: 'demo', salt: 'demo:v1').open();
  final passphrase = passnote.generatePassphrase().join(' ');
  final db = await passnote.openDatabase('home', passphrase: passphrase);
  final items = db.collection<Map<String, dynamic>>(
    'items',
    JsonCodec(
        toMap: (m) => m, fromMap: (m) => m, idOf: (m) => m['id'] as String),
  );
  runApp(DemoApp(items: items));
}

/// Lists the items live and adds one per tap.
class DemoApp extends StatelessWidget {
  /// Creates the app over [items].
  const DemoApp({required this.items, super.key});

  /// The synced collection backing the list.
  final Collection<Map<String, dynamic>> items;

  @override
  Widget build(BuildContext context) => MaterialApp(
        home: Scaffold(
          body: StreamBuilder(
            stream: items.watch(),
            builder: (context, snapshot) {
              final all = snapshot.data ?? const [];
              return ListView(
                children: [
                  for (final item in all)
                    ListTile(title: Text('${item['id']}')),
                ],
              );
            },
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () => items.put({'id': newId()}),
            child: const Icon(Icons.add),
          ),
        ),
      );
}
0
likes
0
points
236
downloads

Publisher

verified publishernodsoftware.net

Weekly Downloads

Passnote for Flutter: the full library plus keychain key store, collection notifier, and batteries-included setup.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_secure_storage, passnote, passnote_crypto, passnote_lan, path, path_provider

More

Packages that depend on passnote_flutter