secure_shared_preferences 0.0.2 copy "secure_shared_preferences: ^0.0.2" to clipboard
secure_shared_preferences: ^0.0.2 copied to clipboard

outdated

Simple to use yet powerful package to encypt shared preferences in android and UserDefaults in iOS.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final TextEditingController _controller = TextEditingController();
  String? data = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              controller: _controller,
            ),
            Text(data ?? ""),
            MaterialButton(
              onPressed: _getData,
              child: const Text("Get It Back"),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _save,
        tooltip: 'Save',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  void _save() async {
    var pref = await SecureSharedPref.getInstance();
    pref.putString("StringEncrypted", "This is my first string test", true);
  }

  _getData() {
    SecureSharedPref.getInstance().then((value) {
      value.getString("StringEncrypted", true).then((value) {
        setState(() {
          data = value.toString();
        });
      });
    });
  }
}
23
likes
0
points
2.93k
downloads

Publisher

verified publisherflutter.pingtobuild.com

Weekly Downloads

Simple to use yet powerful package to encypt shared preferences in android and UserDefaults in iOS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cryptography, cryptography_flutter, flutter, flutter_secure_storage, package_info, shared_preferences

More

Packages that depend on secure_shared_preferences