パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.1.0

cross_local_storage

モバイル(Android/iOS)、Web、デスクトップ(Windows、macOS、Linux)の両方に対応する SharedPreferences のラッパー。また、JSON ファイルストレージも提供します。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
343
いいね数
32
Pub ポイント
160

パッケージをインストール

flutter pub add cross_local_storage

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

CrossLocalStorage は、モバイル(Android/iOS)、Web、デスクトッププラットフォーム(Windows、macOS、Linux)における永続的ストレージを統合的に扱うためのFlutter/Dartパッケージです。モバイルおよびWebではSharedPreferencesをラップし、デスクトップ環境ではJSONファイルベースのストレージを提供します。このパッケージは、プラットフォームにかかわらず一貫したデータアクセスを保証し、クロスプラットフォームアプリ開発を簡素化します。キーと値のストレージ、構造化されたJSONファイルの永続化を両方サポートしており、ユーザー設定やアプリの状態、小さなデータセットを信頼性高く保存するのに最適です。

用途

  • 複数のプラットフォーム間でユーザー設定を保存する
  • マルチプラットフォームアプリでのアプリ状態の永続化
  • 設定ファイルをJSONとして保存する
  • Webおよびデスクトップアプリケーションでのローカルデータの管理
  • モバイルとデスクトップ間で簡単なデータを共有する
  • オフライン優先機能を有効にする

主な機能

  • すべてのプラットフォーム向けの統合 API
  • デスクトップ上のJSONファイルストレージ
  • モバイル/ウェブでのSharedPreferencesのフォールバック
  • プラットフォームに依存しないデータアクセス
  • 文字列、整数、ブール値、および複雑な型をサポートしています
  • 自動シリアル化/逆シリアル化

適している対象

  • クロスプラットフォームのFlutter開発者
  • 複数のターゲットでローカル永続性を必要とするアプリ
  • プラットフォーム固有のコードを避ける開発者
  • ローカルデータにJSONを使用するプロジェクト
  • コード再利用を最優先とするチーム
  • 軽量なローカルストレージを必要とするアプリ

注意事項

  • 大規模なデータには適していません
  • JSON ファイルのストレージはデスクトップのパフォーマンスに影響を与える可能性があります
  • 単純なデータ構造に限定される
  • 組み込みの暗号化なし
  • デスクトップでのファイルパスの取り扱いには注意が必要です
  • 高周波書き込みには対応していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

cross_local_storage

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.

Getting Started

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';
Example
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);

Feature requests and Bug reports

Feel free to post a feature requests or report a bug here.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。