पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv2.0.4

json_store

एक फ्लटर स्टोरेज समाधान जो ब्राउज़र के localStorage के करीब है (लेकिन अत्यधिक शक्तिशाली)

AndroidiOSmacOS
30-दिन डाउनलोड
2.6 हज़ार
लाइक
39
Pub अंक
150

पैकेज इंस्टॉल करें

flutter pub add json_store

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

json_store एक Flutter पैकेज है जो ब्राउज़र localStorage के आधार पर एक स्थायी, NoSQL-जैसा भंडारण समाधान प्रदान करता है। यह Android, iOS और macOS पर ऐप रिस्टार्ट के बाद भी JSON-सीरियलाइज़ेबल डेटा को आसानी से सहेजने और प्राप्त करने में सक्षम बनाता है। सरलता और कार्यक्षमता के लिए डिज़ाइन किया गया, यह असिंक्रोनस ऑपरेशन और स्वचालित सीरियलाइज़ेशन/डी-सीरियलाइज़ेशन का समर्थन करता है, जिससे यह उपयोगकर्ता प्राथमिकताओं, कैश्ड डेटा या छोटे डेटासेट को बिना पूर्ण डेटाबेस सेटअप के स्टोर करने के लिए आदर्श है।

उपयोग

  • उपयोगकर्ता पसंदीदा संग्रहित करना
  • Caching API प्रतिक्रियाएं
  • एप्लिकेशन स्टेट को स्थायी बनाना
  • फॉर्म डेटा सहेजें
  • स्थानीय विन्यास का प्रबंधन
  • ऑफलाइन डेटा का प्रबंधन

मुख्य विशेषताएँ

  • JSON-आधारित भंडारण
  • क्रॉस-प्लेटफ़ॉर्म समर्थन
  • असिंक्रोनस संचालन
  • स्वचालित सीरियलाइज़ेशन
  • सरल API
  • हल्का और तेज़

इनके लिए उपयुक्त

  • छोटे से मध्यम आकार का डेटा स्टोरेज
  • ऑफलाइन क्षमता की आवश्यकता वाले ऐप्स
  • प्रोटोटाइपिंग या एमवीपी विकास
  • सरल डेटा स्थायित्व की आवश्यकता
  • जटिल डेटाबेस से बचने वाले विकासकर्ता

विचार योग्य बातें

  • बड़े डेटासेट के लिए उपयुक्त नहीं
  • सीमित प्रश्न क्षमता
  • कोई एम्बेडेड डेटा सिंक्रनाइजेशन नहीं है
  • सरल की-मान पैटर्न के लिए सबसे अच्छा
  • जटिल संबंधों का समर्थन नहीं करता है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

json_store

A Storage solution somewhat similar to a browser's localStorage in the sence that it is a key value pair storage. The value should be a dart reprisentation of a JSON Object (aka a Map<String, dynamic>)

Features

  • Data is stored in sqflite Database
  • Data may be fully encrypted (encrypt)
  • Encryption keys are stored in Keychain and Keystore thanks to flutter_secure_storage
  • Because the DB schema never changes, there is no concern about database migrations
  • Batch processing
  • Data stored has a time to live. Whenever a getItem is done on a key which ttl has expired, that key will be deleted and a null value will be returned

Getting Started

In your flutter project add the dependency:

dependencies:
  ...
  json_store:
  ...

For help getting started with Flutter, view the online documentation.

Usage example

See example folder for full sample app

Note: JsonStore is a singleton and instantiating with factory constructor JsonStore() will only ever have one instance

Simple example
import 'package:json_store/json_store.dart';

class CounterModel {
  int value;
  CounterModel(this.value);
  CounterModel.fromJson(Map<String, dynamic> json) : this.value = json['value'];
  Map<String, dynamic> toJson() => {'value': value};
}

...

JsonStore jsonStore = JsonStore();
CounterModel counter;

loadFromStorage() async {
  Map<String, dynamic> json = await jsonStore.getItem('counter');
  counter = json != null ? CounterModel.fromJson(json) : CounterModel(0);
}

incrementCounter() async {
  counter.value++;
  await jsonStore.setItem('counter', counter.toJson());
}

...
Batch example

When adding a lot of data at a time (Like a long list of messages), use the batch feature as it will improve performance significantly

class Message {
  final int id;
  final String title;
  final String body;
  
  Message([this.id, this.title, this.body]);
  Message.fromJson(Map<String, dynamic> json)
      : this.id = json['id'],
        this.title = json['title'],
        this.body = json['body'];
  Map<String, dynamic> toJson() => {
        'id': id,
        'title': title,
        'body': body,
      };
}

saveBigList() {
  Batch batch = await jsonStore.startBatch();
  await Future.forEach(_messages, (message) async {
    await jsonStore.setItem(
      'messages-${message.id}',
      message.toJson(),
      batch: batch,
    );
  });
  jsonStore.commitBatch(batch);
}

loadBigList() {
      List<Map<String, dynamic>> json = await jsonStore.getListLike('messages-%');

    messages = json != null
        ? json.map((messageJson) => Message.fromJson(messageJson)).toList()
        : [];

}

Configure Android

In [project]/android/app/build.gradle set minSdkVersion to >= 18.

android {
    ...
    defaultConfig {
        ...
        minSdkVersion 18
        ...
    }
}
Thanks

Thanks to contributors

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 4 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।