solana_seed_vault 0.2.0+1 copy "solana_seed_vault: ^0.2.0+1" to clipboard
solana_seed_vault: ^0.2.0+1 copied to clipboard

PlatformAndroid

A reference implementation of the Seed Vault SDK specification for Flutter.

example/lib/main.dart

import 'package:dfunc/dfunc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wallet_example/bl/bloc.dart';
import 'package:wallet_example/bl/signature_verifier.dart';
import 'package:wallet_example/presentation/limits_section.dart';
import 'package:wallet_example/presentation/seed_list.dart';
import 'package:wallet_example/presentation/seed_section.dart';

void main() {
  runApp(
    BlocProvider<SeedVaultBloc>(
      create: (context) => SeedVaultBloc(const SignatureVerifier())..init(),
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final SeedVaultBloc _bloc;

  @override
  void initState() {
    super.initState();
    _bloc = context.read<SeedVaultBloc>();
  }

  @override
  void dispose() {
    _bloc.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
        home: BlocBuilder<SeedVaultBloc, SeedVaultState>(
          builder: (context, state) => Scaffold(
            appBar: AppBar(
              title: const Text('FakeWallet'),
              actions: [
                IconButton(
                  onPressed: _bloc.refreshUI,
                  icon: const Icon(Icons.refresh),
                ),
              ],
            ),
            body: Center(
              child: state.map(
                none: always(const CircularProgressIndicator()),
                loaded: always(const SeedVaultContent()),
                error: (state) => Text(state.err),
                unauthorized: always(
                  ElevatedButton(
                    onPressed: _bloc.init,
                    child: const Text('Request permission'),
                  ),
                ),
              ),
            ),
          ),
        ),
      );
}

class SeedVaultContent extends StatelessWidget {
  const SeedVaultContent({super.key});

  @override
  Widget build(BuildContext context) => Padding(
        padding: const EdgeInsets.all(16),
        child: CustomScrollView(
          physics: const BouncingScrollPhysics(),
          slivers: [
            SliverList(
              delegate: SliverChildListDelegate(
                [
                  const LimitsSection(),
                  const SizedBox(height: 16),
                  const SeedSection(),
                  const SizedBox(height: 16),
                  const SeedList(),
                ],
              ),
            ),
          ],
        ),
      );
}
1
likes
130
points
25
downloads

Publisher

verified publishercryptoplease.com

Weekly Downloads

A reference implementation of the Seed Vault SDK specification for Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, freezed_annotation, json_annotation, meta, plugin_platform_interface

More

Packages that depend on solana_seed_vault