getNews static method

Future<Data> getNews({
  1. required NewsType newsType,
  2. Language language = Language.en,
  3. int limit = 10,
})

Implementation

static Future<Data> getNews({required NewsType newsType, Language language = Language.en, int limit = 10}) async {
  final http.Response response =
      await http.get(Uri.parse(getNewsEndPoint(newsType: newsType, language: language, limit: limit)));
  GlobalResponse resp = GlobalResponse.fromJson(jsonDecode(response.body));
  if (resp.error!) {
    return Data(newsList: [], message: resp.message);
  } else {
    return Data(newsList: resp.data!.newsList!, message: 'Success');
  }
}