搜索插件、代码仓与 APP 分类

插件详情v2.5.6

shared_preferences

用于读写简单键值对的 Flutter 插件。在 iOS 上封装了 NSUserDefaults,在 Android 上封装了 SharedPreferences。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
909万
喜欢数
1.1万
Pub 分数
160

安装插件

flutter pub add shared_preferences

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可在跨平台环境中实现简单的键值对持久化存储。它抽象了原生 API——iOS 上的 NSUserDefaults 和 Android 上的 SharedPreferences,为存储用户偏好、设置或会话令牌等基本数据提供统一接口。该包支持所有主要平台,包括 Web、macOS、Windows 和 Linux,非常适合轻量级跨平台数据持久化。数据本地存储并异步访问,确保在典型应用场景下的性能和可靠性。

适合场景

  • 存储用户偏好
  • 保存应用设置
  • 保持登录状态
  • 缓存少量数据
  • 跟踪用户会话

主要特点

  • 跨平台兼容性
  • 简单的键值对 API
  • 异步操作
  • 持久化本地存储
  • 支持多个平台

适合对象

  • 轻量级数据存储
  • 用户偏好管理
  • 应用配置
  • 在启动之间保持状态
  • 简单的缓存需求

使用建议

  • 不适用于大型数据集
  • 无查询功能
  • 数据默认情况下未加密
  • 仅限基本类型
  • 不适用于复杂数据结构

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Packages

Release Status Flutter CI Status

This repo is a companion repo to the main flutter repo. It contains the source code for Flutter's first-party packages (i.e., packages developed by the core Flutter team). Check the packages directory to see all packages.

These packages are also available on pub.

Issues

Please file any issues, bugs, or feature requests in the main flutter repo. Issues pertaining to this repository are labeled "package".

Contributing

If you wish to contribute a new package to the Flutter ecosystem, please see the documentation for developing packages. You can store your package source code in any GitHub repository (the present repo is only intended for packages developed by the core Flutter team). Once your package is ready you can publish to the pub repository.

If you wish to contribute a change to any of the existing packages in this repo, please review our contribution guide, and send a pull request.

Packages

These are the packages hosted in this repository:

Package Pub Points Usage Issues Pull requests
animations pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
camera pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
cross_file pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
cupertino_icons pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
cupertino_ui pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
espresso pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
extension_google_sign_in_as_googleapis_auth pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
file_selector pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
flutter_lints pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
flutter_plugin_android_lifecycle pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
flutter_svg pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
flutter_svg_test pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
go_router pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
go_router_builder pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
google_adsense pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
google_fonts pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
google_maps_flutter pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
google_sign_in pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
image_picker pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
interactive_media_ads pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
in_app_purchase pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
local_auth pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
material_ui pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
metrics_center pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
path_parsing pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
path_provider pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
pigeon pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
pointer_interceptor pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
plugin_platform_interface pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
quick_actions pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
google_identity_services_web pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
rfw pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
shared_preferences pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
two_dimensional_scrollables pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
url_launcher pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
vector_graphics pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
vector_graphics_codec pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
vector_graphics_compiler pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
video_player pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
web_benchmarks pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
webview_flutter pub package pub points downloads GitHub issues by-label GitHub pull requests by-label
xdg_directories pub package pub points downloads GitHub issues by-label GitHub pull requests by-label

所属分类

依赖

依赖清单 6 项

  • shared_preferences_android^2.3.4
  • shared_preferences_foundation^2.5.0
  • shared_preferences_linux^2.4.0
  • shared_preferences_platform_interface^2.4.0
  • shared_preferences_web^2.4.0
  • shared_preferences_windows^2.4.0

源码仓库

使用此插件的项目

所在榜单