createEmailAccount static method

Future<Map<String, dynamic>> createEmailAccount({
  1. required String email,
  2. required String password,
  3. String? name,
})

Returns a map with the following keys: if there was no error:

  • user: Account from Appwrite if there was an error:
  • error: true if there was an error
  • type: error if there was an error
  • message: String containing the error message
  • code: int containing the error code

Implementation

static Future<Map<String, dynamic>> createEmailAccount({
  /// Email of the user to signup
  required String email,

  /// Password for the email
  required String password,

  /// Name of the user to signup
  String? name,
}) async {
  try {
    final models.Account userAccount = await _account.create(
      userId: ID.unique(),
      name: name,
      email: email,
      password: password,
    );

    return userAccount.toMap();
  } on AppwriteException catch (e) {
    return {
      'error': true,
      'type': e.type,
      'message': e.message,
      'code': e.code,
    };
  }
}