Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lohanidamodar/appwrite_auth_kit
Making Appwrite Authentication Easy
https://github.com/lohanidamodar/appwrite_auth_kit
appwrite flutter
Last synced: 23 days ago
JSON representation
Making Appwrite Authentication Easy
- Host: GitHub
- URL: https://github.com/lohanidamodar/appwrite_auth_kit
- Owner: lohanidamodar
- License: mit
- Created: 2021-05-06T06:35:06.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T11:03:57.000Z (6 months ago)
- Last Synced: 2025-01-03T04:53:03.847Z (23 days ago)
- Topics: appwrite, flutter
- Language: Dart
- Homepage: https://youtu.be/bqh8qjNCHno
- Size: 276 KB
- Stars: 34
- Watchers: 4
- Forks: 14
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-appwrite - Flutter Appwrite Account Kit
README
# 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
1. Add dependency```yaml
dependencies:
appwrite_auth_kit:
```
1. Wrap your MaterialApp `AppwriteAuthKit` passing a properly initialized Appwrite Client. Example below:```dart
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}class _MyAppState extends State {
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(),
),
);
}
}
```2. Access `authNotifier` from `context`. `authNotifier` is an instance of `AuthNotifier` that provides all the functions of Appwrite's Account service and some easy way to handle authentication.
3. Get `context.authNotifier.status` gets the authentication status which can be one of the `AuthStatus.uninitialized`, `AuthStatus.unauthenticated`, `AuthStatus.authenticating` and `AuthStatus.authenticated`. You can check the status and display the appropriate UI, for example```dart
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;
}
}
```
4. You must use the functions from the `context.authNotifier` instead default Account service from Appwrite SDK to create user, create session (login), delete session (logout), so that the `context.authNotifier?.status` is properly updated and your UI updates accordingly.