get method Null safety

  1. @override
Future<ApklisApiResult> get(
  1. List<String> apps
)
override

Implementation

@override
Future<ApklisApiResult> get(List<String> apps) async {
  try {
    final uri = ApklisWebApi.buildUri(apps);
    final response = await httpClient.get(uri);
    if (response.statusCode == 200) {
      var text = '';
      try {
        text = utf8.decode(response.bodyBytes);
      } on FormatException {
        text = response.body;
      }
      final json = jsonDecode(text) as Map<String, dynamic>;
      final model = ApklisModel.fromJson(json);
      return ApklisApiResult.success(model);
    } else {
      return ApklisApiResult.failure(ApklisErrorModel(
        statusCode: response.statusCode,
        statusMessage: response.reasonPhrase!,
      ));
    }
  } catch (e) {
    return ApklisApiResult.failure(ApklisErrorModel(
      statusCode: -1,
      statusMessage: e.toString(),
    ));
  }
}