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

パッケージ詳細v6.0.0

localstorage

Flutter用のローカルストレージ。React NativeのAsyncStorageの代替です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.3万
いいね数
382
Pub ポイント
160

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

flutter pub add localstorage

パッケージ概要

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

Localstorage は、React Native の AsyncStorage の代替として使用できる、永続的なキー値ストレージを提供する Flutter パッケージです。Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームでアプリ再起動後にデータを保存・取得できます。シンプルさを最優先に設計されており、文字列、数値、JSON にシリアル化可能なオブジェクトの非同期読み書き操作をサポートしています。パッケージはプラットフォーム固有のストレージメカニズムを抽象化し、環境間での一貫した動作を保証します。フルデータベースを必要とせずにキャッシュやユーザー設定、小規模なデータ永続化に適しています。

用途

  • ユーザーの設定を保存する
  • API レスポンスのキャッシュ
  • アプリケーション状態の永続化
  • フォームデータの保存
  • 認証トークンの管理

主な機能

  • クロスプラットフォーム互換性
  • 非同期の読み取り/書き込み操作
  • JSON シリアル化のサポート
  • シンプルな API
  • 軽量で高速

適している対象

  • 小規模なデータ永続化
  • オフライン優先のアプリ
  • ユーザー設定の管理
  • Prototyping
  • 軽量ストレージを必要とするアプリ

注意事項

  • 大規模なデータセットには適していません
  • 組み込みのクエリ機能なし
  • デフォルトではデータは暗号化されていません
  • 基本的なデータ型に限定
  • 手動でのエラー処理が必要です

元の README

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

LocalStorage

LocalStorage for Flutter.

[!IMPORTANT]
LocalStorage is not intended to store large amounts or sensitive data.

Installation

flutter pub add localstorage

or add dependency to pubspec.yaml manually

dependencies:
  localstorage: ^5.0.0

API docs

LocalStorage API documentation

Usage

import 'package:flutter/material.dart';
import 'package:localstorage/localstorage.dart';

late final ValueNotifier<int> notifier;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initLocalStorage();

  notifier = ValueNotifier(int.parse(localStorage.getItem('counter') ?? '0'));
  notifier.addListener(() {
    localStorage.setItem('counter', notifier.value.toString());
  });

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ValueListenableBuilder<int>(
            valueListenable: notifier,
            builder: (context, value, child) {
              return Text('Pressed $value times');
            },
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            notifier.value++;
          },
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}

Contributors

License

MIT

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

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