create method

Future<User> create({
  1. required String userId,
  2. String? email,
  3. String? phone,
  4. String? password,
  5. String? name,
})

Create a new user.

Implementation

Future<models.User> create({
  required String userId,
  String? email,
  String? phone,
  String? password,
  String? name,
}) async {
  final String apiPath = '/users';

  final Map<String, dynamic> apiParams = {
    'userId': userId,
    if (email != null) 'email': email,
    if (phone != null) 'phone': phone,
    if (password != null) 'password': password,
    if (name != null) 'name': name,
  };

  final Map<String, String> apiHeaders = {
    'X-Appwrite-Project': client.config['project'] ?? '',
    'content-type': 'application/json',
    'accept': 'application/json',
  };

  final res = await client.call(
    HttpMethod.post,
    path: apiPath,
    params: apiParams,
    headers: apiHeaders,
  );

  return models.User.fromMap(res.data);
}