Viewing version 2.4.28. Open the latest package page.

shared_preferences_android

2.4.28

Android implementation of the shared_preferences plugin

Download archive

Readme

shared_preferences_android

The Android implementation of shared_preferences.

Usage

This package is endorsed, which means you can simply use shared_preferences normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

Options

The [SharedPreferencesAsync] and [SharedPreferencesWithCache] APIs can use DataStore Preferences or Android SharedPreferences to store data.

To use the Android SharedPreferences backend, use the SharedPreferencesAsyncAndroidOptions when using [SharedPreferencesAsync].

const SharedPreferencesAsyncAndroidOptions options = SharedPreferencesAsyncAndroidOptions(
  backend: SharedPreferencesAndroidBackendLibrary.SharedPreferences,
  originalSharedPreferencesOptions: AndroidSharedPreferencesStoreOptions(
    fileName: 'the_name_of_a_file',
  ),
);

The [SharedPreferences] API uses the native Android SharedPreferences tool to store data.

Changelog

2.4.28

  • Updates pigeon dev_dependency to ^27.3.2 for analyzer 14 compatibility.

2.4.27

  • Converts legacy backend to Kotlin.

2.4.26

  • Updates internal implementation to use Kotlin Pigeon.

2.4.25

  • Bumps the test-dependencies group across 2 directories with 1 update.
  • Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

2.4.24

  • Migrates to Built-in Kotlin to support AGP 9.
  • Updates minimum supported SDK version to Flutter 3.44/Dart 3.12.

2.4.23

  • Fixes dartdoc comments that accidentally used HTML.

2.4.22

  • Updates build files from Groovy to Kotlin.

2.4.21

  • Reverts androidx.datastore:datastore to 1.1.7 due to a regression 16 KB page size support in 1.2.0.
  • Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

2.4.20

  • Bumps androidx.datastore:datastore from 1.1.7 to 1.2.0.

2.4.19

  • Bumps kotlin_version to 2.3.0.

2.4.18

  • Bumps kotlin_version to 2.2.21.

2.4.17

  • Bumps com.android.tools.build:gradle from 8.12.1 to 8.13.1.

2.4.16

  • Updates to Pigeon 26.
  • Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.

2.4.15

  • Resolves Gradle 9 deprecations.

2.4.14

  • Updates Java compatibility version to 17.
  • Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

2.4.13

  • Bumps androidx.datastore:datastore from 1.1.3 to 1.1.7.

2.4.12

  • Bumps com.android.tools.build:gradle to 8.12.1 and kotlin_version to 2.2.10.
  • Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

2.4.11

  • Updates kotlin version to 2.2.0 to enable gradle 8.11 support.

2.4.10

  • Removes obsolete code related to supporting SDK <21.

2.4.9

  • Enables callers to use getInt to read preference of type int that was written to shared preferences by native code without passing though plugin code.

2.4.8

  • Updates compileSdk 34 to flutter.compileSdkVersion.

2.4.7

  • Updates datastore to 1.1.3.

2.4.6

  • Ensures that platform messages on background queues are handled in order.

2.4.5

  • Bumps gradle-plugin to 2.1.10.

2.4.4

  • Restores the behavior of throwing a TypeError when calling getStringList on a value stored with setString.

2.4.3

  • Migrates List<String> value encoding to JSON.

2.4.2

  • Bumps gradle-plugin to 2.1.0.

2.4.1

  • Bumps kotlin version to 1.9.10 androidx.datastore:datastore from 1.0.0 to 1.1.1.

2.4.0

  • Adds SharedPreferences support within SharedPreferencesAsyncAndroid API.

2.3.4

  • Restrict types when decoding preferences.

2.3.3

  • Updates Java compatibility version to 11.
  • Updates minimum supported SDK version to Flutter 3.24/Dart 3.5.

2.3.2

  • Bumps com.android.tools.build:gradle from 7.2.2 to 8.5.1.

2.3.1

  • Fixes getStringList returning immutable list.

2.3.0

  • Adds new SharedPreferencesAsyncAndroid API.

2.2.4

  • Updates lint checks to ignore NewerVersionAvailable.

2.2.3

  • Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
  • Removes support for apps using the v1 Android embedding.

2.2.2

  • Updates minSdkVersion to 19.
  • Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
  • Updates compileSdk version to 34.
  • Updates mockito to 5.2.0.

2.2.1

  • Adds pub topics to package metadata.
  • Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
  • Deletes deprecated splash screen meta-data element.

2.2.0

  • Adds clearWithParameters and getAllWithParameters methods.
  • Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.

2.1.4

  • Fixes compatibility with AGP versions older than 4.2.

2.1.3

  • Adds a namespace for compatibility with AGP 8.0.

2.1.2

  • Sets the required Java compile version to 1.8 for new features used in 2.1.1.

2.1.1

  • Updates minimum Flutter version to 3.0.
  • Converts implementation to Pigeon.

2.1.0

  • Adds getAllWithPrefix and clearWithPrefix methods.

2.0.17

  • Clarifies explanation of endorsement in README.
  • Aligns Dart and Flutter SDK constraints.
  • Updates compileSdkVersion to 33.

2.0.16

  • Updates links for the merge of flutter/plugins into flutter/packages.
  • Updates minimum Flutter version to 3.0.

2.0.15

  • Updates code for stricter lint checks.

2.0.14

  • Fixes typo in SharedPreferencesAndroid docs.
  • Updates code for no_leading_underscores_for_local_identifiers lint.

2.0.13

  • Updates gradle to 7.2.2.
  • Updates minimum Flutter version to 2.10.

2.0.12

  • Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.

2.0.11

  • Switches to an in-package method channel implementation.

2.0.10

  • Removes dependency on meta.

2.0.9

  • Updates compileSdkVersion to 31.

2.0.8

  • Split from shared_preferences as a federated implementation.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'shared_preferences_android:2.4.28'
pubspec.yaml
name: shared_preferences_android
description: Android implementation of the shared_preferences plugin
repository: https://github.com/flutter/packages/tree/main/packages/shared_preferences/shared_preferences_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
version: 2.4.28

environment:
  sdk: ^3.12.0
  flutter: ">=3.44.0"

flutter:
  plugin:
    implements: shared_preferences
    platforms:
      android:
        package: io.flutter.plugins.sharedpreferences
        pluginClass: SharedPreferencesPlugin
        dartPluginClass: SharedPreferencesAndroid

dependencies:
  flutter:
    sdk: flutter
  meta: ^1.10.0
  shared_preferences_platform_interface: ^2.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  pigeon: ^27.3.2

topics:
  - persistence
  - shared-preferences
  - storage

Version history

VersionPublishedArchiveSHA-256
2.0.8On demandDownload042776e2…fe02e3
2.0.9On demandDownload54eead0b…be9b35
2.0.10On demandDownloadeb5f8ca2…29e708
2.0.11On demandDownloadbc236594…f532a6
2.0.12On demandDownload853801ce…0dd39c
2.0.13On demandDownload3e128864…b38007
2.0.14On demandDownload8e251f3c…d1ab97
2.0.15On demandDownload955e9736…e8c8f7
2.0.16On demandDownloada51a4f93…879db4
2.0.17On demandDownloadad423a80…c1c521
2.1.0On demandDownload8304d8a1…8873f6
2.1.1On demandDownload1bc5d734…a5d90b
2.1.2On demandDownload7fa90471…97db46
2.1.3On demandDownload5d7b3bd0…dc0c1b
2.1.4On demandDownload6478c6bb…02c749
2.2.0On demandDownloadfe8401ec…438076
2.2.1On demandDownload8568a389…80fb06
2.2.2On demandDownload1ee8bf91…64a1f2
2.2.3On demandDownload93d0ec9d…131577
2.2.4On demandDownload3d4571b3…3a8ec1
2.3.0On demandDownload041be4d9…4a0294
2.3.1On demandDownloada7e8467e…c0d974
2.3.2On demandDownload480ba434…bbba7e
2.3.3On demandDownload3b9febd8…ade5ab
2.3.4On demandDownload7f172d1b…d0c549
2.4.0On demandDownload02a7d8a9…41863d
2.4.1On demandDownloadbf808be8…9dbd84
2.4.2On demandDownload138b7bbb…80a4f5
2.4.3On demandDownload986dc7b7…541b01
2.4.4On demandDownload650584dc…9cce1f
2.4.5On demandDownloadea86be7b…9e9f16
2.4.6On demandDownloada768fc8e…a03c22
2.4.7On demandDownload9f9f3d37…bda2b1
2.4.8On demandDownload3ec72108…79b7ad
2.4.9On demandDownloadc2c8c462…8e1a18
2.4.10On demandDownload20cbd561…bfb6ac
2.4.11On demandDownload5bcf0772…42379e
2.4.12On demandDownloada2608114…269e74
2.4.13On demandDownloadbd144361…c74d9e
2.4.14On demandDownload0b0f98d5…3d181f
2.4.15On demandDownload34266009…fcb713
2.4.16On demandDownload07d552db…b0c43b
2.4.17On demandDownload46a46fd6…bacc7b
2.4.18On demandDownload83af5c68…3556bc
2.4.20On demandDownloadcbc40be9…644a6f
2.4.21On demandDownload8374d620…84fb41
2.4.22On demandDownload8c04d0a3…ca8bab
2.4.23On demandDownloade8d4762b…5e2c53
2.4.24On demandDownload67724122…693a01
2.4.25On demandDownloada2c49fc1…f99cf0
2.4.26On demandDownload93ae5884…d088f5
2.4.27On demandDownload0634e64b…2b5cc7
2.4.28Cached · Upstream SHA-256 matchedDownload1e12aafe…7b3399
2.5.0On demandDownloadb90caa27…4c793e
2.5.1On demandDownloada67a1a6a…104a76
2.5.2On demandDownload732b86c5…077336
2.5.3On demandDownload593034a1…cdce09
2.5.4On demandDownload33b38b07…73b002

Dependencies

flutter { "sdk": "flutter" }

meta "^1.10.0"

shared_preferences_platform_interface "^2.4.0"