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 ↗