sendMobileOTP method

Future<GotrueJsonResponse> sendMobileOTP(
  1. String phone
)

Sends a mobile OTP via SMS. Will register the account if it doesn't already exist

phone is the user's phone number WITH international prefix

Implementation

Future<GotrueJsonResponse> sendMobileOTP(String phone) async {
  try {
    final body = {'phone': phone};
    final fetchOptions = FetchOptions(headers);
    final response =
        await _fetch.post('$url/otp', body, options: fetchOptions);
    if (response.error != null) {
      return GotrueJsonResponse.fromResponse(response: response);
    } else {
      return GotrueJsonResponse.fromResponse(
        response: response,
        data: response.rawData as Map<String, dynamic>?,
      );
    }
  } catch (e) {
    return GotrueJsonResponse(error: GotrueError(e.toString()));
  }
}