Git Product home page Git Product logo

flutter_async_storage's Introduction

flutter_async_storage

flutter_async_storage reads data from React Native's AsyncStorage from within Flutter apps. This is useful for Flutter apps that have migrated from React Native and need to access data stored on disk.

Reading data

To read data from AsyncStorage in Flutter, you can use a workflow like:

final asyncStorageReader = AsyncStorageReader(LocalPlatform());
try {
if (await asyncStorageReader.exists()) {
    final data = await asyncStorageReader.data('myDataKey');

    // Do something with data...

    // Clear AsyncStorage.
    await asyncStorageReader.clear();
}
} catch (e) {
// Handle error.
}

Using data

Data in AsyncStorage is keyed; you can use the data() method on AsyncStorageReader to read arbitrary keys. Data returned is stringified JSON, which you can deserialize to another format. built_value allows you to create custom deserializers which are helpful for converting data to Dart objects.

Platform specific code

flutter_async_storage can read from AsyncStorage on both Android and iOS. On Android, AsyncStorage data is stored in a SQLite database in the table RKStorage. On iOS, AsyncStorage data is stored in the filesystem (in a manifest file for smaller data, and sharded into separate files for larger data using a hash function). flutter_async_storage mimics the path taken to retrive data by React Native's AsyncStorage.

The platform must be specified in the constructor for AsyncStorageReader, but the API is the same.

flutter_async_storage's People

Contributors

phil-nova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.