Flutter preferences management with crypto capabilities

Overview

crypted_preferences

Flutter preferences management with crypto capabilities

For now preferences are not crypted, I'm waiting for FFI to land :)

But you can still use this package to have multiple preferences files in Desktop, mobile and web.

Usage

final preferences = await Preferences.preferences({path: 'pathToPrefs'});

preferences.getBool('boolKey');
await preferences.setBool('boolKey', false);

API

Get and set preference:

Getter have an optional param defaultValue if the preference if not set.

dynamic get(key)

bool getBool(key)

Future<bool> setBool(key, value)

int getInt(key)

Future<bool> setInt(key, value)

double getDouble(key)

Future<bool> setDouble(key, value)

String getString(key)

Future<bool> setString(key, value)

List<String> getStringList(key)

Future<bool> setStringList(key, value)

Custom object save as preferences

You can use save custom object using the mixin WithPreferencesSerializable on your class, it will serialize your object into a map to save it.

Retrieve an object from a preference key: WithPreferencesSerializable getPreferencesSerializable(String key, WithPreferencesSerializable Function(Map<String, Object>))

Retrieve an object from a preference file WithPreferencesSerializable getPreferences(String key, WithPreferencesSerializable Function(Map<String, Object>))

Remove preference:

Future remove(key)

Clear all preference:

Future clear()

You might also like...

Flutter Settings Screen with Shared Preferences

Settings Screen with Shared Preferences A library that provides an easy solution to create settings screens with simple and compound options. Features

Sep 27, 2022

Flutter-Shared-Preference - The goal is to learn how to use the shared preferences plugin to save important pieces of information to your device.

Flutter-Shared-Preference - The goal is to learn how to use the shared preferences plugin to save important pieces of information to your device.

Recipe Finder The goal is to learn how to use the shared preferences plugin to save important pieces of information to your device. Final App UI Resou

Jan 1, 2022

🌀 Shared preferences with RxDart Stream observation

🌀 Shared preferences with RxDart Stream observation

🌀 Shared preferences with RxDart Stream observation ⚡️ Reactive shared preferences for Flutter 🌸Reactive stream wrapper around SharedPreferences 🍄 Lightweight and easy-to-use 🌱 A reactive key-value store for Flutter projects. Like shared_preferences, but with Streams 📕 Rx Shared Preferences for Flutter 🌿 rx_shared_preferences 🌰 rx_shared_preference 🍷 Reactive SharedPreferences for Flutter 🌰 A stream based wrapper over shared_preferences, allowing reactive key-value storage.

Nov 4, 2022

Shared Preferences ile ekran açılma sayacı uygulaması

sayac_uygulamasi A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Dec 29, 2021

A package for encrypted shared preferences

Prefs Guard Prefs Guard is a data protection wrapper for local storage (Shared Prefs). supporting both IOS & Android. - Notice :- Use Same GuardType t

Jun 7, 2022

Crypto Loss Gain Calculator App build with Flutter. It developed with DDD (Domain Driven Design) principles.

Crypto Loss Gain Calculator App build with Flutter. It developed with DDD (Domain Driven Design) principles.

Crypto Loss Gain Calculator Crypto Loss Gain Calculator App build with Flutter. It developed with DDD (Domain Driven Design) principles. Domain-Driven

Dec 27, 2022

🦀🦀 High performance Crypto library of Rust implementation for Flutter

r_crypto Rust backend support crypto flutter library, much faster than Dart-implementation library, light-weight library. Some crypto support hardware

Dec 17, 2022

A sample app to showcase Crypto Wallet App UI demo in flutter.

A sample app to showcase Crypto Wallet App UI demo in flutter.

Flutter-Crypto-Wallet-App A sample app to showcase Crypto Wallet App UI demo in flutter. Development Setup Clone the repository and run the following

Dec 14, 2022

Cryptowallet - Crypto Wallet -- personal project

app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is y

Dec 22, 2022
Comments
  • file does not get loaded and setString() returns false

    file does not get loaded and setString() returns false

    import 'dart:async';
    
    import 'package:crypted_preferences/crypted_preferences.dart';
    import 'package:flutter/material.dart';
    
    class Pref {
      static Completer<Preferences> _completer;
    
      static Future<Preferences> getInstance(path) async {
        if (_completer == null) {
          _completer = Completer<Preferences>();
          try {
            final test = await Preferences.preferences(path: path);
            _completer.complete(test);
          } on Exception catch (e) {
            _completer.completeError(e);
            final Future<Preferences> prefFuture = _completer.future;
            _completer = null;
            return prefFuture;
          }
        }
        return _completer.future;
      }
    }
    
    class AppBody extends StatefulWidget {
      @override
      _AppBodyState createState() => _AppBodyState();
    }
    
    class _AppBodyState extends State<AppBody> {
      double _sliderValue = 1;
      Preferences preferences;
      TextEditingController tec = new TextEditingController();
    
      @override
      void initState() {
        loadSavedData();
    
        super.initState();
      }
    
      Future<void> loadSavedData() async {
        preferences = await Pref.getInstance('./lib/prefs');
    //    preferences = await Preferences.preferences(path: "save");
        print(preferences.containsKey('tmp'));
        print(preferences.getString('tmp'));
        setState(() {
          if (preferences.containsKey('tmp')) tec.text = preferences.getString('tmp');
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return getBody();
      }
    
      getBody() {
        return Container(
            child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text((tec.text == null || tec.text == "") ? "Empty value" : tec.text),
            TextFormField(
              controller: tec,
            ),
            RaisedButton(
              child: Text("Save"),
              onPressed: () async {
                if (await preferences.setString('tmp', tec.text)) {
                  setState(() {});
                  print(preferences.get('tmp'));
                } else {
                  setState(() {
                    tec.text = "";
                  });
                }
              },
            )
          ],
        ));
      }
    

    The above code does not save/load the values.

    opened by praharshbhatt 3
  • A bug that causes corrupted prefs-file due to simultaneous writes is …

    A bug that causes corrupted prefs-file due to simultaneous writes is …

    …fixed in this pull request

    If one uses multiple setValue calls in his/her application, each call causes async writeAsString call. This can lead to the file corruption. At least I found that effect on Linux Desktop platform. To solve this problem I propose a delayed write: setValue just create a delayd task for writing. It no other setValue-s are called the writing occures while if new setValue comes the delay shifts a little bit to the future.

    opened by svok 0
Owner
Jimmy Aumard
Open source enthousiaste !
Jimmy Aumard
Shared preferences typed - A type-safe wrapper around shared preferences, inspired by ts-localstorage

Typed Shared Preferences A type-safe wrapper around shared_preferences, inspired

Philipp Bauer 0 Jan 31, 2022
Buy me crypto coffee - A Flutter package that helps you to integrate Buy me a crypto coffee widget in flutter

Buy me a crypto coffee Features A Flutter package that helps you to integrate Bu

Anto Tom Abraham 2 Nov 25, 2022
Crypto-currency - A Flutter application showing crypto currency rates

Features Crypto Currency rates This application allows to view crypto currency rates from Coin Market Cap. Getting started Get an API key at Coin Mark

Karol Lisiewicz 16 Oct 26, 2022
Crypto-App - Crypto App Using Flutter and Firebase

Crypto App Technologies and tools used in practice: Flutter library in the Dart

Kushal Shingote 2 Nov 14, 2022
ITS A SIMPLE CRYPTO APP THAT GIVES OR DISPLAYS PRICES - %CHANGE AND CHANGE VALUE OF TICKER (VARIOUS CRYPTO ASSERTS)

btcpricetracker A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

jatin upadhyay 0 Dec 28, 2021
A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

?? Crypto Trackers ?? Crypto Currency ?? A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange t

Prashant Kumar Singh 10 Dec 3, 2022
A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

Prashant Kumar Singh 10 Dec 3, 2022
WhereIsMoney - A money expense tracker with online and offline capabilities

WhereIsMoney ?? A money expense tracker to help you know where your money is goi

Junior Medehou 4 Feb 6, 2022
Flutter theme demo using riverpod and shared preferences

flutter_theme_demo A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Andree Yosua 0 Dec 27, 2021
Flutter settings manager built on top of Shared Preferences

Settings Manager Flutter settings store built on top of shared preferences. Code Generator for supported types Usage import 'dart:async'; import 'pac

Rody Davis 17 Dec 13, 2022