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的認可或隸屬。