send method Null safety

Future<LCStatus> send()

Send a status to users matching a LCQuery.

Implementation

Future<LCStatus> send() async {
  LCUser? user = await LCUser.getCurrent();
  if (user == null) {
    throw ArgumentError.notNull('current user');
  }

  Map formData = {
    InboxTypeKey: inboxType,
  };
  formData['data'] = _LCEncoder.encode(data);
  if (query != null) {
    Map queryData = {'className': query!.className};
    Map<String, dynamic> params = query!._buildParams();
    if (params.containsKey('where')) {
      queryData['where'] = jsonDecode(params['where']);
    }
    if (params.containsKey('keys')) {
      queryData['keys'] = params['keys'];
    }
    formData['query'] = queryData;
  }
  Map<String, dynamic> response = await LeanCloud._httpClient.post('statuses', data: formData);
  _LCObjectData objectData = _LCObjectData.decode(response);
  _merge(objectData);
  return this;
}