valt 0.0.2+1 copy "valt: ^0.0.2+1" to clipboard
valt: ^0.0.2+1 copied to clipboard

Valt is a Flutter plugin that enables easy reading and writing of simple key-value pairs with AES encryption for secure local storage.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Valt Demo',
      home: MyHomePage(),
    );
  }
}

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

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _key = 'value';
  final _defaultValue = 'Not Stored';
  String? _value;

  @override
  void initState() {
    super.initState();
    _getValue();
  }

  Future<void> _getValue() async {
    final value = await Valt.getString(_key);
    setState(() {
      _value = value ?? _defaultValue;
    });
  }

  Future<void> _setValue(String value) async {
    await Valt.setString(_key, value);
    setState(() {
      _value = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Valt Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              'Stored Value:',
              style: Theme.of(context).textTheme.headline6,
            ),
            Text(
              _value != null ? _value! : "",
              style: Theme.of(context).textTheme.bodyText1,
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () => _setValue('Hello, Flutter!'),
              child: const Text('Store Value'),
            ),
          ],
        ),
      ),
    );
  }
}
7
likes
0
pub points
24%
popularity

Publisher

verified publishermufassalhussain.com

Valt is a Flutter plugin that enables easy reading and writing of simple key-value pairs with AES encryption for secure local storage.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

crypto, encrypt, path_provider

More

Packages that depend on valt