Making Appwrite Authentication Easy

Overview

FlAppwrite Account Kit

A Flutter wrapper for Appwrite's Accounts service, makes it easy to use manage authentication and account features.

Under development. Not ready for production. Help get ready for production.

Getting Started

This is really very easy to use

  1. Add dependency from git (Will only publish to pub if enough people are interested to use and help make it better.)
dependencies:
    flappwrite_account_kit:
        git: https://github.com/lohanidamodar/flappwrite_account_kit
  1. Wrap your MaterialApp FlAppwriteAccountKit passing 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 FlAppwriteAccountKit(
      client: client,
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MainScreen(),
      ),
    );
  }
}
  1. 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.
  2. 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
class MainScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final authNotifier = context.authNotifier;

    Widget widget;
    switch (authNotifier?.status ?? AuthStatus.uninitialized) {
      case AuthStatus.authenticated:
        widget = AdminPage();
        break;
      case AuthStatus.unauthenticated:
      case AuthStatus.authenticating:
        widget = LoginPage();
        break;
      case AuthStatus.uninitialized:
      default:
        widget = LoadingPage();
        break;
    }
    return widget;
  }
}
  1. 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.
You might also like...

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Flutter Auth App (Login, Register, Google Login, Facebook Login, Apple Login) To use this client, get the server up and running. Try it out now! App S

Jan 4, 2023

Flutter Firebase Complete Authentication with getx

flutfire A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Oct 12, 2022

Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...).

Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...).

Flutter Locker ๐Ÿ”’ Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...). It uses: Lo

Nov 21, 2022

Authentication + Splash Screen Flutter UI, UI created getting inspired from one share on dribble with flutter

Authentication + Splash Screen Flutter UI, UI created getting inspired from one share on dribble with flutter

Rest App, with Firebase Auth + SplashScreen UI created getting inspired from one share on dribble with flutter, after getting amazing responce, Added

Dec 17, 2022

A chat app built on Flutter with firebase authentication and image sharing capability.

A chat app built on Flutter with firebase authentication and image sharing capability.

Flutter Chat App A one-to-one chat app built on Flutter with firebase authentication and image sharing capability. For help getting started with Flutt

Dec 27, 2022

Flutter user authentication with back-end handler

Flutter user authentication with back-end handler

user_auth Dart - Backend user auth helpe, with common methods Show some โค๏ธ and star the repo usage import package:user_auth/user_auth.dart. create ins

Jan 2, 2022

In this video we will learn how to Integrate NodeJS Login and Register API in our Flutter application using JWT Token Authentication.

In this video we will learn how to Integrate NodeJS Login and Register API in our Flutter application using JWT Token Authentication.

Flutter Login & Register with Node JS Rest API In this video we will learn how to Integrate NodeJS Login and Register API in our Flutter application u

Nov 28, 2022

Flutter Firebase Authentication

Flutter Firebase Authentication A sample project demonstrating firebase email and password authentication with Flutter. Getting Started You will need

Dec 13, 2021

Flutter app for authentication using Text Belt API

Flutter app for authentication using Text Belt API

๐ŸŒŸ Flutter TextBelt API ๐ŸŒŸ Flutter app for authentication using Text Belt API ๐ŸŒ Links ๐ŸŒ ๐Ÿ“‚ Repo ยท ๐Ÿš€ Got Issue ๐Ÿš€ Features Authenticated user with O

Nov 9, 2021
Comments
  • createSession directly sets the user as Authenticated

    createSession directly sets the user as Authenticated

    This can be the expected behavior in some cases but in others it is required that the user's email in verified, in such cases the createSession method must be called to check the emailVerification property.

    The createSession method could be called in these cases:

    • Login (check email is verified).
    • Singup (send verification email).
    • Resend verification email.

    I don't know what it is the best way to tackle this, but I suggest to consider these options:

    • Have two different AuthStatus states: authenticatedVerified and authenticatedNotVerified instead of authenticated.
    • Include and optional parameter notifyListeners = true in createSession and deleteSession, so these methods can be used for signing up and resending verification emails.
    opened by JaviBonilla 5
  • Get `$id` without context

    Get `$id` without context

    Is there a way to get the $id of the current user in initState, since I can't use context there?

    Here is an example:

    @override
    void initState() {
        super.initState();
        boatsStream = DB.boat.streamBoats(uid); // Initialize the stream
    }
    

    I somehow need to get the users id here. But it's not only initState functions where I need to get the $id without context, for example in the toMap function of some of my models I also need it.

    opened by PlutoHDDev 2
  • I'm getting error  when I was trying to use package with GetX package

    I'm getting error when I was trying to use package with GetX package

    ======== Exception caught by widgets library =======================================================
    The following assertion was thrown building MainScreen(dirty, dependencies: [FlAppwriteAccountKit]):
    setState() or markNeedsBuild() called during build.
    
    This Overlay widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
    The widget on which setState() or markNeedsBuild() was called was: Overlay-[LabeledGlobalKey<OverlayState>#c5b77]
      state: OverlayState#cee5b(entries: [OverlayEntry#62e83(opaque: true; maintainState: false), OverlayEntry#a96c4(opaque: false; maintainState: true), OverlayEntry#82e01(opaque: false; maintainState: false), OverlayEntry#fdc08(opaque: false; maintainState: true)])
    The widget which was currently being built when the offending call was made was: MainScreen
      dirty
      dependencies: [FlAppwriteAccountKit]
    The relevant error-causing widget was: 
      MainScreen MainScreen:file:///Users/ruslan/StudioProjects/wizard_game/lib/main.dart:20:15
    When the exception was thrown, this was the stack: 
    #0      Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:4424:11)
    #1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4439:6)
    #2      State.setState (package:flutter/src/widgets/framework.dart:1141:15)
    #3      OverlayState.rearrange (package:flutter/src/widgets/overlay.dart:444:5)
    #4      NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:3950:16)
    #5      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4438:5)
    #6      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4366:5)
    #7      GetNavigation.to (package:get/get_navigation/src/extension_navigation.dart:522:37)
    #8      MainScreen.build (package:wizard_game/app/modules/login/views/main_screen.dart:23:13)
    #9      StatelessElement.build (package:flutter/src/widgets/framework.dart:4827:28)
    #10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4754:15)
    #11     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
    #12     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4735:5)
    #13     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4729:5)
    ...     Normal element mounting (171 frames)
    #184    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
    #185    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6422:36)
    #186    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6433:32)
    ...     Normal element mounting (403 frames)
    #589    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
    #590    Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
    #591    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1198:16)
    #592    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1167:5)
    #593    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1112:18)
    #594    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2600:19)
    #595    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1111:13)
    #596    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:944:7)
    #597    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:924:7)
    (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
    ====================================================================================================
    D/eglCodecCommon(28630): setVertexArrayObject: set vao to 0 (0) 1 0
    W/OpenGLRenderer(28630): dequeueBuffer failed, error = -110; switching to fallback
    W/Gralloc3(28630): allocator 3.x is not supported
    W/OpenGLRenderer(28630): reserveNext failed, error = -2147483648 (Unknown error -2147483648)
    D/EGL_emulation(28630): eglMakeCurrent: 0xd541a420: ver 3 0 (tinfo 0xd540fd30)
    E/flutter (28630): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 2845 pos 18: '!navigator._debugLocked': is not true.
    E/flutter (28630): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
    E/flutter (28630): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
    E/flutter (28630): #2      _RouteEntry.handlePush.<anonymous closure> (package:flutter/src/widgets/navigator.dart:2845:18)
    E/flutter (28630): #3      TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:407:15)
    E/flutter (28630): #4      _rootRunUnary (dart:async/zone.dart:1434:47)
    E/flutter (28630): #5      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
    E/flutter (28630): <asynchronous suspension>
    E/flutter (28630): #6      TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:406:5)
    E/flutter (28630): <asynchronous suspension>
    E/flutter (28630): 
    I/ght.wizard_gam(28630): WaitForGcToComplete blocked HeapTrim on None for 26.313ms
    
    ======== Exception caught by widgets library =======================================================
    The following assertion was thrown building MainScreen(dirty, dependencies: [FlAppwriteAccountKit]):
    'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4429 pos 12: '!_debugLocked': is not true.
    
    
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=2_bug.md
    
    
    The relevant error-causing widget was: 
      MainScreen MainScreen:file:///Users/ruslan/StudioProjects/wizard_game/lib/main.dart:20:15
    When the exception was thrown, this was the stack: 
    #2      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4429:12)
    #3      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4366:5)
    #4      GetNavigation.to (package:get/get_navigation/src/extension_navigation.dart:522:37)
    #5      MainScreen.build (package:wizard_game/app/modules/login/views/main_screen.dart:15:13)
    #6      StatelessElement.build (package:flutter/src/widgets/framework.dart:4827:28)
    #7      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4754:15)
    #8      Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
    #9      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
    #10     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
    #11     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
    #12     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
    #13     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
    #14     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
    #18     _invoke (dart:ui/hooks.dart:151:10)
    #19     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
    #20     _drawFrame (dart:ui/hooks.dart:115:31)
    (elided 5 frames from class _AssertionError and dart:async)
    ====================================================================================================
    
    
    opened by AlimFreight 1
Releases(0.7.0)
  • 0.7.0(Jan 2, 2023)

    What's Changed

    • updated to support appwrite sdk 8.2.0 by @lohanidamodar in https://github.com/lohanidamodar/appwrite_auth_kit/pull/15

    Full Changelog: https://github.com/lohanidamodar/appwrite_auth_kit/compare/0.6.0...0.7.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Oct 30, 2022)

    What's Changed

    • Upgrade to appwrite v1 by @fballan93 in https://github.com/lohanidamodar/appwrite_auth_kit/pull/14

    New Contributors

    • @fballan93 made their first contribution in https://github.com/lohanidamodar/appwrite_auth_kit/pull/14

    Full Changelog: https://github.com/lohanidamodar/appwrite_auth_kit/compare/0.5.0...0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Aug 31, 2022)

  • 0.4.0(Aug 31, 2022)

  • 0.3.0(Jul 4, 2022)

    What's Changed

    • update to latest appwrite version by @lohanidamodar in https://github.com/lohanidamodar/appwrite_auth_kit/pull/9
    • updates to support appwrite 0.15 by @lohanidamodar in https://github.com/lohanidamodar/appwrite_auth_kit/pull/11

    Full Changelog: https://github.com/lohanidamodar/appwrite_auth_kit/compare/0.1.0...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Apr 23, 2022)

Owner
Damodar Lohani
Tech Consultant | Open source enthusiast | โค Flutter | Full stack Developer
Damodar Lohani
Simple app for easy shopping list making, developed with simplicity in mind.

Fast Shopping Fast Shopping is a mobile application developed with simplicity in mind. It allows you on having a simple set of shopping lists, that yo

Albert Wolszon 208 Dec 31, 2022
Notes App created with Flutter and Appwrite.

Note Keeper A Flutter + AppWrite Project Note Keeper is a Note Creater App build with Flutter backed by AppWrite (An Open-Source Backend Server) ?? Fu

Tekeshwar Singh 13 Oct 22, 2022
continue to my flutter journey here's the comeback repo , lets see what i will end up making

flutter_application_1 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Nerajan kc 3 May 19, 2021
Purpose of this project is to create extendable architecture of making platform aware Widgets which automatically select platform specific implementation

Old good factory Main obstacle in creating native experience on Flutter is the fact that you are asked to rebuild two layouts using platform specific

Swav Kulinski (Robotoaster) 101 Oct 14, 2022
A composable API for making HTTP requests in Dart.

A composable, Future-based library for making HTTP requests. This package contains a set of high-level functions and classes that make it easy to cons

Dart 888 Dec 26, 2022
๐Ÿ’ณ A Flutter package for making payments via credo central. Provides support for both Android and iOS

?? Credo Package for Flutter TODO: Put a short description of the package here that helps potential users know whether this package might be useful fo

Samuel Abada 0 Dec 26, 2021
Hangman and yet another gaming App(i love games and making it XD)

and yet another gaming App(i love games and making it XD) , i completed the ui and almost all the functionality , i will add some storing data using firebase later, anyways please give a try and enjoy it , i will try in the future to use flame engine to make a 3d cool app or even 2d, any feedback will be apperciated since im still halfway to be a proffesional

FarZ 15 Dec 29, 2022
AdventOfCode 2022 in Dart focusing on code golf, making the solutions as small as possible

Advent of Code 2022 in Dart (Code Golf) This is my attempt at solving the Advent of Code 2022 puzzles in the shortest possible code using Dart 2.18. Y

Pascal Welsch 5 Dec 15, 2022
This is a JazzCash UI clone ( Modern Wallet App in Pakistan), implementing modern app bar animmation. One can take a concept of making app bar with animation.

jazzcash_ui This is a JazzCash UI clone ( Modern Wallet App in Pakistan), implementing modern app bar animmation. One can take a concept of making app

null 9 Nov 27, 2022
A flutter widget to indicate loading progress. Easy to use, easy to extend

?? ?? ?? A flutter widget to indicate loading progress. Easy to use, easy to extend

Manuel Duarte 2 May 30, 2022