createUser method

Future<User> createUser({
  1. String? userId,
  2. String? username,
  3. String? email,
  4. String? image,
  5. String? password,
  6. dynamic metadata,
})

Implementation

Future<User> createUser({
  String? userId,
  String? username,
  String? email,
  String? image,
  String? password,
  dynamic metadata,
}) async {
  HeraRequest req = HeraRequest();
  User user = User();
  user.id = userId ?? "";
  user.username = username ?? "";
  user.email = email ?? "";
  user.image = image ?? "";
  user.password = password ?? "";
  req.cloudToken = await _authorize.getAccessToken();
  req.user = user;
  req.namespace = namespace;
  if (metadata != null) {
    String encodeMetadata = jsonEncode(metadata);
    user.metadata = encodeMetadata;
  }
  try {
    HeraResponse resp = await grpcUserClient.createUser(req);
    return resp.user;
  } catch (e) {
    if (debug == true) {
      print("could not create user with err: " + e.toString());
    }
    rethrow;
  }
}