패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.10

native_shared_preferences

이 패키지는 키에 접두사가 없는 shared_preferences 패키지의 사본입니다. 이전 네이티브 앱에서 데이터를 마이그레이션하는 데 사용됩니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
180
좋아요
34
Pub 점수
130

패키지 설치

flutter pub add native_shared_preferences

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

공유된 선호도 패키지와 동일한 기능을 하지만 키 접두사가 없는 가벼운 지속성 키-값 저장 솔루션으로 작동하는 Flutter/Dart 패키지입니다. 기존 네이티브 애플리케이션에서 데이터를 마이그레이션하기 위해 특별히 설계되었으며, 원래의 키 이름을 유지함으로써 기존에 저장된 데이터와의 원활한 호환성을 보장합니다. 간단한 크로스플랫폼 데이터 지속성과 추가 오버헤드 없이 필요한 앱에 이상적입니다. 이 패키지는 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

소스 저장소

이 패키지를 사용하는 프로젝트