sendSMS method Null safety

Future<double> sendSMS(
  1. {required String token,
  2. required String to,
  3. required String from,
  4. required String text}

Sends an SMS to a single user retutns the remaining balance after the sms is sent


Future<double> sendSMS({
  required String token,
  required String to,
  required String from,
  required String text,
}) async {
  final uri = Uri.https(authority, '/v1/sms/');
  final payload = {'to': to, 'text': text, 'sender': from};
  _dio.options.headers = {'Authorization': 'Bearer $token'};
  late Response<Map<String, dynamic>> res;
  Map data;

  try {
    res = await _dio.postUri(uri, data: payload);
    data = as Map<String, dynamic>;
  } on DioError catch (e, s) {
    throw PindoError(
      message: (e.response?.data as Map)['message'],
      statusCode: (e.response?.data as Map)['status'] ?? res.statusCode,
      type: e.type.valueToString,
      stackTrace: s,
  } on TypeError {
    throw PindoCastingError();
  } on Exception {

  if (data.containsKey('remaining_balance')) {
    return data['remaining_balance'];
  throw PindoUnexpectedResponseError(
    expected: 'remaining_balance',
    received: data,