Authenticating with Appwrite
Appwrite provides an authentication service that we can use to authenticate our application users. Appwrite’s authentication supports anonymous authentication, email- and password-based authentication, as well as OAuth authentication using lots of different OAuth providers, including Google, Facebook, and LinkedIn. We will start by implementing anonymous login, which is a very useful feature if you don’t want to keep track of any user details. We are already using the MVVM pattern, so we can implement anonymous login in our auth view model. Follow these steps:
- Open
lib/app/view_models/auth.vm.dart
and first import and instantiate the account service provided by Appwrite. - Import
package:appwrite/appwrite.dart
:class AuthVM extends ChangeNotifier { bool isLoggedIn = false; String error = ''; UserVM? User; final Account account = Account(AppwriteService.instance.client); ...