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

パッケージ詳細v2.0.10

native_shared_preferences

このパッケージは、キーにプレフィックスがない shared_preferences パッケージのコピーです。以前のネイティブアプリからのデータ移行に使用されます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
180
いいね数
34
Pub ポイント
130

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

flutter pub add native_shared_preferences

パッケージ概要

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

Flutter/Dartパッケージで、shared_preferencesパッケージと同等の機能を持つ軽量かつ永続的なキー値ストレージソリューションですが、キーにプレフィックスがありません。従来のネイティブアプリケーションからのデータ移行を目的としており、元のキー名を保持することで既存の保存データとのシームレスな互換性を確保します。シンプルでクロスプラットフォームのデータ永続化が必要なアプリに最適です。このパッケージはAndroid、iOS、Web、macOS、Windows、Linuxなどすべての主要プラットフォームをサポートしています。

用途

  • ネイティブアプリからのデータ移行
  • ユーザーの設定を保存する
  • セッション間でアプリの状態を保持する
  • クロスプラットフォームデータストレージ
  • シンプルなキー値データ管理

主な機能

  • キーのプレフィックスなし
  • 直接的なデータ移行のサポート
  • マルチプラットフォーム互換性
  • 軽量で高速
  • 既存のコードとの簡単な統合

適している対象

  • レガシー アプリの移行
  • シンプルなデータ永続化の必要性
  • クロスプラットフォームアプリ
  • 直接キーへのアクセスが必要な開発者
  • 重要なネームスペースの衝突を回避するアプリ

注意事項

  • 大規模なデータセットには推奨されません
  • 基本的なキー値ストレージに限定
  • 組み込みの暗号化なし
  • キー名の付け方に注意が必要です
  • 下位のプラットフォームストレージメカニズムに依存します

元の README

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

Migration Shared Preferences

===========

Codemagic build status

This plugin is a copy of the shared_preferences package but without the prefix in the keys. Is used to migrate the data from previous native app.

The issue is that flutter add a prefix to the keys when read and write. So we can not read our old keys. Also for Android you can now specify name of your resource file in android/app/src/main/res/values/strings.xml:

<resources>
    ...
    <string name="flutter_shared_pref_name">resource_name</string>
    ...
</resources>

ISSUE https://github.com/flutter/flutter/issues/52544

Only use this plugin when is needed get the shared preferences from previous native app version. For other situation use the official shared preferences package.

To manage the migration use this package https://pub.dev/packages/version_migration/

Installation

Add in pubspec:

native_shared_preferences: ^2.0.10

Usage

To use this plugin, add native_shared_preferences in your pubspec.yaml file

Example
import 'package:flutter/material.dart';
import 'package:native_shared_preferences/native_shared_preferences.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
      child: RaisedButton(
        onPressed: _incrementCounter,
        child: Text('Increment Counter'),
        ),
      ),
    ),
  ));
}

_incrementCounter() async {
  NativeSharedPreferences prefs = await NativeSharedPreferences.getInstance();
  int counter = (prefs.getInt('counter') ?? 0) + 1;
  print('Pressed $counter times.');
  await prefs.setInt('counter', counter);
}
Testing

You can populate NativeSharedPreferences with initial values in your tests by running this code:

NativeSharedPreferences.setMockInitialValues (Map<String, dynamic> values);

カテゴリー

依存関係

依存関係一覧 9 件

  • cupertino_icons^1.0.6
  • file^7.0.0
  • meta^1.9.1
  • shared_preferences^2.2.2
  • shared_preferences_linux^2.3.2
  • shared_preferences_macos^2.0.5
  • shared_preferences_platform_interface^2.3.1
  • shared_preferences_web^2.2.1
  • shared_preferences_windows^2.3.2

ソースリポジトリ

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