Rank 3: Container
Here is my code, I've narrowed it down to currentUserId = await _account().get(); and the _getUser(); which run the same code during login.
//sign in method using email or username
@override FutureEither signIn( {required String email, required String password, required BuildContext context}) async { try { if (isValidEmail(email)) { final session = await context.authNotifier .createEmailSession(email: email, password: password); _currentUser = await _account.get();
return right(session); } else { final document = await _db.listDocuments( databaseId: AppwriteConstants.databaseId, collectionId: AppwriteConstants.usersCollection, queries: [ Query.search('userName', email), ], ); final user = UserModel.fromMap(document.documents.first.data); final responseWithUserName = await context.authNotifier.createEmailSession( email: user.email, password: password, ); _currentUser = await _account.get();
return right(responseWithUserName); } } on AppwriteException catch (e, stackTrace) { return left( Failure(e.message ?? 'Some unexpected error occurred', stackTrace)); } catch (e, stackTrace) { return left( Failure(e.toString(), stackTrace), ); } }```