sendEmailOtp method

Future<Map<String, dynamic>> sendEmailOtp({
  1. required String? email,
  2. required BuildContext context,
  3. String flag = 'add_contact_info',
})

Implementation

Future<Map<String, dynamic>> sendEmailOtp(
    {required String? email,
    required BuildContext context,
    String flag = 'add_contact_info'}) async {
  try {
    final http.Response result =
        await client.query(generateEmailOTPQuery, <String, dynamic>{
      'email': email,
    }) as http.Response;
    toggleLoadingIndicator(context: context, flag: flag, show: false);
    final Map<String, dynamic> body =
        client.toMap(result) as Map<String, dynamic>;
    if (client.parseError(body) != null) {
      return <String, dynamic>{
        'status': 'error',
      };
    }
    return <String, dynamic>{
      'status': 'ok',
      'otp': json.decode(result.body)['data']['emailVerificationOTP'],
    };
  } catch (e) {
    return <String, dynamic>{
      'status': 'error',
    };
  }
}