the_storage 0.0.15 copy "the_storage: ^0.0.15" to clipboard
the_storage: ^0.0.15 copied to clipboard

A fast and secure storage library for Flutter: store key and iv in FlutterSecureStorage and individual iv for every record in SQLite

example/lib/main.dart

// This is an example app, so we don't need public member API docs.
// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:developer' as developer;

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

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TheStorage Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    unawaited(TheStorage.i().init());
  }

  @override
  void dispose() {
    unawaited(TheStorage.i().dispose());
    super.dispose();
  }

  Future<void> writeDb() async {
    await TheStorage.i().set('myKey', 'myValue');
    developer.log("write to DB: myKey: 'myValue'");
  }

  Future<void> readDb() async {
    developer.log(
      "read from DB: myKey: '${await TheStorage.i().get('myKey')}'",
    );
  }

  Future<void> clearDb() async {
    await TheStorage.i().clearAll();
    developer.log('clear DB');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ElevatedButton(
              onPressed: writeDb,
              child: const Text('Write to DB'),
            ),
            ElevatedButton(
              onPressed: readDb,
              child: const Text('Read from DB'),
            ),
            ElevatedButton(
              onPressed: clearDb,
              child: const Text('Clear DB'),
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
160
points
131
downloads

Documentation

API reference

Publisher

verified publisherthenes.xyz

Weekly Downloads

A fast and secure storage library for Flutter: store key and iv in FlutterSecureStorage and individual iv for every record in SQLite

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

collection, drift, drift_flutter, encrypt, flutter, flutter_secure_storage, logging, path, path_provider, rxdart

More

Packages that depend on the_storage