cross_local_storage
모바일(안드로이드/아이오스), 웹 및 데스크톱(윈도우, 맥OS, 리눅스) 모두를 위한 SharedPreferences 래퍼입니다. 또한 JSON 파일 저장 기능도 제공합니다.
모바일(안드로이드/아이오스), 웹 및 데스크톱(윈도우, 맥OS, 리눅스)용 SharedPreferences 래퍼입니다.
{"sdk":"flutter"}^2.5.3{"sdk":"flutter"}^5.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Build Pub GitHub GitHub stars
Wraps NSUserDefaults (on iOS and macOS), SharedPreferences (on Android), LocalStorage (on Web) and JSON file (on Windows and Linux), providing a persistent store for simple data. Data is persisted to disk asynchronously. Neither platform can guarantee that writes will be persisted to disk after returning and this plugin must not be used for storing critical data.
In order to use this plugin, add dependency in the pubspec.yaml:
cross_local_storage: any
or
cross_local_storage:
git:
url: https://github.com/marchdev-tk/cross_local_storage
Add an import to dart file:
import 'package:cross_local_storage/cross_local_storage.dart';
import 'package:flutter/material.dart';
import 'package:cross_local_storage/cross_local_storage.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: RaisedButton(
onPressed: _incrementCounter,
child: Text('Increment Counter'),
),
),
),
));
}
_incrementCounter() async {
LocalStorageInterface prefs = await LocalStorage.getInstance();
int counter = (prefs.getInt('counter') ?? 0) + 1;
print('Pressed $counter times.');
await prefs.setInt('counter', counter);
Feel free to post a feature requests or report a bug here.