dispatch method Null safety

  1. @override
Future<bool> dispatch(
  1. String json

Sends the given json to the backend.


Future<bool> dispatch(String json) async {
  if (_ingestToken.isEmpty == true) throw 'Humio ingest token is not defined';
  if (ingestUrl.isEmpty == true) throw 'Humio ingest URL is not defined';

  var dio = Dio();

  Response<dynamic> response;
  try {
    response = await dio.post(
      data: json,
      options: Options(
        contentType: 'application/json',
        headers: {'Authorization': 'Bearer $_ingestToken'},
  } on DioError catch (e) {
    print('Humio log error: ${e.message}');

    return false;

  return response.statusCode == 200;