secure_store 0.1.2+1 copy "secure_store: ^0.1.2+1" to clipboard
secure_store: ^0.1.2+1 copied to clipboard

Zero-config wallet components for starknet

example/lib/main.dart

// ignore_for_file: use_build_context_synchronously

import 'package:flutter/material.dart';
import 'package:secure_store/secure_store.dart';

void main() {
  PasswordStore.init();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Secure Store Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Secure Store Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Spacer(),
            const Text(
              'Password Store',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            FilledButton(
              child: const Text('Store secret'),
              onPressed: () async {
                await PasswordStore(password: '1234').storeSecret(
                  secret: "Simplicity is the ultimate sophistication",
                  key: "password-store:secret",
                );
                show(context, 'Stored secret');
              },
            ),
            FilledButton(
              child: const Text('Get secret'),
              onPressed: () async {
                final secret = await PasswordStore(password: '1234').getSecret(
                  key: "password-store:secret",
                );
                show(context, 'Got secret: $secret');
              },
            ),
            FilledButton(
              child: const Text('Delete secret'),
              onPressed: () async {
                await PasswordStore(password: '1234').deleteSecret(
                  key: "password-store:secret",
                );
                show(context, 'Deleted secret');
              },
            ),
            const Spacer(),
            const Text(
              'Biometrics Store',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            FilledButton(
              child: const Text('Store secret'),
              onPressed: () async {
                await BiometricsStore().storeSecret(
                    secret: "Simplicity is the ultimate sophistication",
                    key: "biometrics-store:secret");
                show(context, 'Stored secret');
              },
            ),
            FilledButton(
              child: const Text('Get secret'),
              onPressed: () async {
                final secret = await BiometricsStore().getSecret(
                  key: "biometrics-store:secret",
                );
                show(context, 'Got secret: $secret');
              },
            ),
            FilledButton(
              child: const Text('Delete secret'),
              onPressed: () async {
                await BiometricsStore().deleteSecret(
                  key: "biometrics-store:secret",
                );
                show(context, 'Deleted secret');
              },
            ),
            const Spacer(),
          ],
        ),
      ),
    );
  }
}

show(BuildContext context, String message) {
  ScaffoldMessenger.of(context).hideCurrentSnackBar();
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text(message),
    ),
  );
}
0
likes
140
points
52
downloads

Publisher

verified publishergabinmarignier.com

Weekly Downloads

Zero-config wallet components for starknet

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter, hive_flutter, pointycastle

More

Packages that depend on secure_store