搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫yeniel/native_shared_preferences

native_shared_preferences

yeniel/native_shared_preferences open-source repository details.

native_shared_preferences 專案封面
星標
7
分支
56
最近推送(UTC)
2024年10月16日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

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);
Yeniel GitHub avatar
GitHub 作者

Yeniel ↗

Madrid
語言DartJavaObjective-CRuby

此儲存庫發佈的套件

使用的依賴

依賴清單 11 項

  • flutter{"sdk":"flutter"}
  • meta^1.9.1
  • shared_preferences^2.2.2
  • shared_preferences_platform_interface^2.3.1
  • shared_preferences_linux^2.3.2
  • shared_preferences_macos^2.0.5
  • shared_preferences_web^2.2.1
  • shared_preferences_windows^2.3.2
  • file^7.0.0
  • cupertino_icons^1.0.6
  • flutter_test開發依賴{"sdk":"flutter"}

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗