AWS Amplify提供了不同类别的云操作的声明性且易于使用的接口。我们的默认实现可与Amazon Web Services(AWS)一起使用,但AWS Amplify旨在为任何自定义后端或服务开放且可插入。有关扩增框架的更多详细信息,请参见AWS放大。
我们正在迭代并寻找反馈和协作,所以请让我们知道您对我们的方向和路线图的反馈。
入门指南
请使用Amplify Flutter的最新版本(V2)。如果您当前正在使用V1,请按照以下说明升级到V2。
| 图书馆 | Pub.Dev包 | 描述 |
|---|---|---|
| 验证 | 对于想要使用Amazon Cognito创建用户身份验证体验的开发人员的API和构建块。 | |
| 分析 | 轻松通过精确收集应用程序的分析数据。分析数据包括您要在应用中跟踪的用户会话和其他自定义事件。 | |
| 贮存 | 提供了一种简单的机制,可以使用Amazon S3在公共,受保护或私人存储存储桶中为您的应用程序管理用户内容。 | |
| 数据存储 | 一个用于利用共享和分布式数据的编程模型,而无需为离线和在线方案编写其他代码,这使得使用分布式的跨用户数据与使用本地数据一样简单。 | |
| API(休息) | 提出HTTP请求时提供了一个简单的解决方案。它提供了一个自动轻巧的签名过程,该过程符合AWS签名版本4。 | |
| API(GraphQl) | 与您的GraphQL Server或AWS AppSync API与易于使用和配置的GraphQl客户端进行交互。 | |
| 通知 | 在用户接收或打开通知时,触发将通知触发通知并记录指标。 | |
| 身份验证者 | 放大的颤动身份验证器通过提供完全可用的流量来简化用户身份验证用户的过程。只需将应用程序的身份验证路线包装在身份验证器组件中,就可以为您处理身份验证用户和管理登录课程的过程。 |
我们遵循发行版的语义版本控制。
当Amplify添加新的枚举条目或密封类子类型时,我们将发布新的库库版本。
使用switch语句评估枚举类型的所有成员的应用程序可以添加default条款,以防止新案件引起编译警告或错误。
我们遵循语义版本来更新依赖关系。这包括更新飞镖和Flutter SDK版本。
| 类别 | 安卓 | ios | 网络 | 视窗 | macos | Linux |
|---|---|---|---|---|---|---|
| 分析 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| API(休息) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| API(GraphQl) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 验证 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 数据存储 | ✅ | ✅ | ? | ? | ? | ? |
| 贮存 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 通知 | ✅ | ✅ | ? | ? | ? | ? |
For Flutter的放大是一个开源项目,欢迎Flutter社区的贡献,请参阅贡献。
打开您的扑朔迷离的项目。如果您没有一个活动的颤音项目,则可以在终端安装扑朔迷离的开发工具和跑步flutter create <project-name>一个项目。
使用Amplify CLI,从项目的根源中运行amplify init :
如果您尚未配置放大CLI,请在Amplify CLI安装中查看我们的文档。
== > amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project < project-name >
The following configuration will be applied:
Project information
| Name: < project-name >
| Environment: dev
| Default editor: Visual Studio Code
| App type: flutter
| Configuration file location: ./lib/
? Initialize the project with the above configuration ? Yes
Using default provider awscloudformation
? Select the authentication method you want to use: AWS profile
For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
? Please choose the profile you want to use default添加放大类别(为此示例选择默认值):
$ amplify add auth # Choose default configuration after entering this command in your terminal.将更改推向云以提供后端资源:
$ amplify push在您的pubspec.yaml文件中,将以下内容添加到dependencies :
注意:请勿在您在应用中未使用的
pubspec文件中包含依赖项。这可能会在基础SDK中导致配置错误。
dependencies :
amplify_auth_cognito : ^2.0.0
amplify_authenticator : ^2.0.0
amplify_flutter : ^2.0.0
flutter :
sdk : flutterflutter pub get import 'package:amplify_auth_cognito/amplify_auth_cognito.dart' ;
import 'package:amplify_authenticator/amplify_authenticator.dart' ;
import 'package:amplify_flutter/amplify_flutter.dart' ;
import 'package:flutter/material.dart' ;
import 'amplifyconfiguration.dart' ;
void main () {
runApp ( const MyApp ());
}
class MyApp extends StatefulWidget {
const MyApp ({ super .key});
@override
State < MyApp > createState () => _MyAppState ();
}
class _MyAppState extends State < MyApp > {
@override
void initState () {
super . initState ();
_configureAmplify ();
}
Future < void > _configureAmplify () async {
try {
await Amplify . addPlugin ( AmplifyAuthCognito ());
await Amplify . configure (amplifyconfig);
safePrint ( 'Successfully configured' );
} on Exception catch (e) {
safePrint ( 'Error configuring Amplify: $ e ' );
}
}
@override
Widget build ( BuildContext context) {
return Authenticator (
child : MaterialApp (
builder : Authenticator . builder (),
home : const Scaffold (
body : Center (
child : Text ( 'You are logged in!' ),
),
),
),
);
}
}由于Amplify Flutter支持6个带有弹力的平台,包括iOS,Android,Web和桌面,因此每个平台可能需要一些额外的配置。查看平台设置指南,以确保您完成了必要的步骤。
运行flutter run以在连接的设备上启动您的应用程序。
加载应用后,点击配置放大,然后在记录事件上几次。
要查看您重新编码的事件,请运行amplify console analytics 。这将在默认的Web浏览器中为您的项目打开Amazon Pinpoint控制台。在大约一分钟之内,您应该开始在当时的“ Pinpoint”控制台的“事件”部分中看到填充事件。
恭喜,您已经构建了第一个Amplify应用程序! ?
有关进一步的文档并放大类别用法,请参见文档。
Flutter和相关徽标是Google LLC的商标。我们不受Google LLC的认可或隶属。