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

पैकेज विवरणv0.1.0

flutter_cache

एक सरल कैश पैकेज फ्लटर के लिए। यह पैकेज साझा प्रेफरेंस के लिए एक लेपर है और साझा प्रेफरेंस के साथ काम करने में आसान बनाता है।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
1.9 हज़ार
लाइक
22
Pub अंक
120

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

flutter pub add flutter_cache

पैकेज अवलोकन

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

flutter_cache एक हल्का पैकेज है जो Flutter एप्लिकेशन में साझा प्राथमिकताओं के साथ काम करने को सरल बनाता है। यह साझा प्राथमिकताओं के चारों ओर एक वрапर के रूप में काम करता है, जो ऐप रीस्टार्ट के बाद डेटा को स्थायी रूप से स्टोर और पुनः प्राप्त करने के लिए आसान उपयोग वाला API प्रदान करता है। सरलता और दक्षता के लिए डिज़ाइन किया गया, यह सभी प्रमुख प्लेटफॉर्मों का समर्थन करता है, जिसमें Android, iOS, Web, macOS, Windows और Linux शामिल हैं। पैकेज आम कैशिंग ऑपरेशन को अब्सट्रैक्ट करता है, जिससे यह छोटी मात्रा में स्थायी डेटा जैसे उपयोगकर्ता सेटिंग्स, टोकन या कैश्ड रिस्पॉन्स के प्रबंधन के लिए आदर्श है।

उपयोग

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

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

  • सरल API
  • साझा प्रेफ़रेंस वैपर
  • क्रॉस-प्लेटफ़ॉर्म समर्थन
  • आसान डेटा सीरियलाइज़ेशन
  • हल्का और तेज़

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

  • शुरुआती Flutter विकासकर्ता
  • मूल अवधारणा की आवश्यकता वाले ऐप्स
  • छोटे पैमाने का डेटा स्टोरेज
  • त्वरित प्रोटोटाइपिंग
  • सरल कैशिंग की आवश्यकता

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

  • बड़े डेटासेट के लिए उपयुक्त नहीं
  • केवल कुंजी-मान भंडारण के लिए सीमित
  • कोई बिल्ट-इन समाप्ति तंत्र नहीं
  • साझा प्रेफ़रेंस प्रदर्शन पर निर्भर है
  • जटिल प्रश्नों का समर्थन नहीं करता है

मूल README

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

flutter_cache

Dependencies Status file size GitHub Issues follows on twitter

A simple cache package for flutter. This package is a wrapper for shared preference and makes working with shared preference easier. Once it has been installed, you can do these things.

import 'package:flutter_cache/flutter_cache.dart' as cache;

// create new cache.
cache.remember('key', 'data'); 
cache.write('key', 'data'); 

// add Cache lifetime on create
cache.remember('key', 'data', 120); 
cache.write('key', 'data', 120); 

// load Cache by key
cache.load('key'); // This will load the cache data.

// return `defaultValue` if key not exists
cache.load('key', 'defaultValue')

// destroy single cache by key
cache.destroy('key');

// destroy all cache
cache.clear();

Getting Started

Installation

First include the package dependency in your project's pubspec.yaml file

dependencies:
  flutter_cache: ^0.1.0

You can install the package via pub get:

flutter pub get

Then you can import it in your dart code like so

import 'package:flutter_cache/flutter_cache.dart' as cache;
What Can this Package Do ?
  1. Cache String, Map, List<String> and List<Map> for forever or for a limited time.
  2. Load the cache you've cached.
  3. Clear All Cache.
  4. Clear Single Cache.
Usage
Cache Fetch Data from API

If data already exist, then it will use the data in the cache. If it's not, It will fetch the data. You can also set Cache lifetime so your app would fetch again everytime the Cache dies.

import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter_cache/flutter_cache.dart' as cache;

var employees = await cache.remember('employees', () async {
  var response = await http.get('http://dummy.restapiexample.com/api/v1/employees');
  return jsonDecode(response.body)['data'].cast<Map>();
}, 120); // cache for 2 mins

// or 

// cache for 2 mins
var employees = await cache.remember(
    'servers', 
    () async => jsonDecode( 
        (await http.get( 'http://dummy.restapiexample.com/api/v1/employees' )
    ).body )['data'].cast<Map>()
, 120);
Saved data for limited time

The data will be destroyed when it reached the time you set.

cache.remember('key', 'data', 120); // saved for 2 mins or 120 seconds
cache.write('key', 'data', 120);
Cache multipe datatype

You can cache multiple datatype. Supported datatype for now are String, Map, List<String> and List<Map>. When you use cache.load() to get back the data, it will return the data in the original datatype.

cache.remember('key', { 
  'name' : 'Ashraf Kamarudin',
  'depth2' : {
    'name' : 'depth2',
    'depth3' : {
      'name': 'depth3'
    } 
  }
});

cache.load('key'); // will return data in map datatype.

श्रेणियाँ

निर्भरताएँ

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

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

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