appwrite_auth_kit
讓 Appwrite 認證變得簡單
- 星標
- 34
- 分支
- 14
- 最近推送(UTC)
- 2024年8月2日
- 專案狀態
- 未封存
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
Appwrite Auth Kit
A Flutter wrapper for Appwrite's Accounts service, makes it easy to use manage authentication and account features.
Getting Started
This is really very easy to use
- Add dependency
dependencies:
appwrite_auth_kit: <version>
- Wrap your MaterialApp
AppwriteAuthKitpassing a properly initialized Appwrite Client. Example below:
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late Client client;
@override
void initState() {
super.initState();
//initialize your client
client = Client();
client
.setEndpoint('https://localhost/v1')
.setProject('60793ca4ce59e')
.setSelfSigned();
}
@override
Widget build(BuildContext context) {
return AppwriteAuthKit(
client: client,
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MainScreen(),
),
);
}
}
- Access
authNotifierfromcontext.authNotifieris an instance ofAuthNotifierthat provides all the functions of Appwrite's Account service and some easy way to handle authentication. - Get
context.authNotifier.statusgets the authentication status which can be one of theAuthStatus.uninitialized,AuthStatus.unauthenticated,AuthStatus.authenticatingandAuthStatus.authenticated. You can check the status and display the appropriate UI, for example
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authNotifier = context.authNotifier;
Widget widget;
switch (authNotifier.status) {
case AuthStatus.authenticated:
widget = AdminPage();
break;
case AuthStatus.unauthenticated:
case AuthStatus.authenticating:
widget = LoginPage();
break;
case AuthStatus.uninitialized:
default:
widget = LoadingPage();
break;
}
return widget;
}
}
- You must use the functions from the
context.authNotifierinstead default Account service from Appwrite SDK to create user, create session (login), delete session (logout), so that thecontext.authNotifier?.statusis properly updated and your UI updates accordingly.
語言DartCMakeC++RubySwiftHTMLCKotlinObjective-C
分類
使用的依賴
依賴清單 4 項
- appwrite
^12.0.0 - flutter
{"sdk":"flutter"} - flutter_lints開發依賴
^4.0.0 - flutter_test開發依賴
{"sdk":"flutter"}
如何選擇適合專案的儲存庫?
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
- 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
- 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
- 使用前在 GitHub 確認 README、授權條款與 Issues。
來源與維護
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗