newsapi 2.0.0 copy "newsapi: ^2.0.0" to clipboard
newsapi: ^2.0.0 copied to clipboard

Use the NewsApi v2 service in Dart. The library has a clear return structure and an easy-to-use API.

example/main.dart

import 'package:newsapi/newsapi.dart';

void main() async {
  var newsApi = NewsApi(
    //  dioOptions: dioOptions,
    //  interceptors: interceptors,
    debugLog: true,
    apiKey: 'foo',
  );

  newsApi.apiKey = 'Change_your_api_key';

  var topHeadlines = await newsApi.topHeadlines(
//    country: country,
//    category: category,
//    sources: sources,
//    q: q,
    language: 'en',
//    pageSize: pageSize,
//    page: page,
  );

  // ArticleResponse
  print(topHeadlines);

  var everything = await newsApi.everything(
    q: 'flutter',
//    qInTitle: qInTitle,
//    sources: sources,
//    domains: domains,
//    excludeDomains: excludeDomains,
//    from: from, // support DateTime or String
//    to: to, // support DateTime or String
//    language: language,
//    sortBy: sortBy,
//    pageSize: pageSize,
//    page: page,
  );
  // ArticleResponse
  print(everything);

  var sources = await newsApi.sources(
//    category: category,
//    language: language,
//    country: country,
      );
  // SourceResponse
  print(sources);
}
10
likes
130
pub points
0%
popularity

Publisher

verified publisheryeungkc.com

Use the NewsApi v2 service in Dart. The library has a clear return structure and an easy-to-use API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, equatable, json_annotation, pretty_dio_logger, retrofit

More

Packages that depend on newsapi