一个纯 Dart 实现的 Amplify 安全存储,专为跨平台应用设计。它在桌面平台上利用 dart:ffi,在 Web 平台上利用 dart:html 来安全地存储令牌和凭据等敏感数据。该包通过抽象平台特定的安全机制,确保在 iOS、Web、macOS、Windows 和 Linux 上行为一致。非常适合在 Flutter 应用中使用 Amplify 的开发者,他们需要无需原生代码依赖的安全加密本地存储。
适合场景
存储身份验证令牌
安全保存用户凭据
持久化加密密钥
管理会话数据
支持多平台应用的加密存储
主要特点
纯 Dart 实现
使用 dart:ffi 进行桌面开发
在 web 上使用 dart:html
跨平台兼容性
加密本地存储
适合对象
Flutter 应用针对多个平台
需要安全本地数据持久化的应用
基于 Amplify 的应用程序
避免原生代码的开发者
面向 Web 和桌面的 Flutter 项目
使用建议
需要 Flutter 3.0 或更高版本
仅限 dart:ffi 和 dart:html 支持的平台
无原生 iOS/Android SDK 依赖
安全性依赖于底层平台的实现
不适合高性能、低级别存储需求
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Amplify Flutter
AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. Our default implementation works with Amazon Web Services (AWS), but AWS Amplify is designed to be open and pluggable for any custom backend or service. See AWS Amplify for further details about the Amplify Framework.
We are iterating and looking for feedback and collaboration, so please let us know your feedback on our direction and roadmap.
⚠️ Amplify Flutter v1 is deprecated as of April 30th, 2025. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.
Please use the latest version (Gen 2) of Amplify Flutter. If you are currently using v1, follow these instructions to upgrade to v2.
Easily collect analytics data for your app with Pinpoint. Analytics data includes user sessions and other custom events that you want to track in your app.
A programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios, which makes working with distributed, cross-user data just as simple as working with local-only data.
Provides a simple solution when making HTTP requests. It provides an automatic, lightweight signing process which complies with AWS Signature Version 4.
The Amplify Flutter Authenticator simplifies the process of authenticating users by providing a fully-customizable flow which just works. Simply wrap your app's authenticated route in an Authenticator component and the process of authenticating users and managing login sessions is handled for you.
When Amplify adds a new enumeration entry or sealed class subtype, we will publish a new minor version of the library.
Applications that use a switch statement to evaluate all members of an enumerated type can add a default clause to prevent
new cases from causing compile warnings or errors.
Open your Flutter project. If you do not have an active Flutter project, you can create one after installing the Flutter development tooling and running flutter create <project-name> in your terminal.
Run the following to create an amplify project:
npm create amplify@latest -y
To use the Authenticator, you need to add the following dependencies to your project:
Deploy your backend use Amplify's per-developer cloud sandbox. This feature provides a separate backend environment for every developer on a team, ideal for local development and testing. To run your application with a sandbox environment, you can run the following command:
Since Amplify Flutter supports 6 platforms with Flutter including iOS, Android, Web, and Desktop, some extra configuration may be required for each platform. Check out the Platform Setup guide to make sure you've completed the necessary steps.
Run flutter run to launch your app on the connected device.
Congratulations, you've built your first Amplify app! 🎉
For further documentation and Amplify Category usage, see the documentation.
Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.