news_api_flutter_package 2.0.0
news_api_flutter_package: ^2.0.0 copied to clipboard
A Dart/Flutter client for News API (newsapi.org), with type-safe enum parameters, structured responses, and no unnecessary dependencies.
2.0.0 #
Breaking changes #
getTopHeadlines/getEverythingnow returnArticlesResponse(.articles,.totalResults) instead of a bareList<Article>.category,language,country,sortByandsearchInare now typed enums (NewsCategory,NewsLanguage,NewsCountry,ArticleSortBy,ArticleSearchIn) instead of raw strings.sources,domainsandexcludeDomainsnow take aList<String>instead of a comma-separatedString.Article.publishedAtis now aDateTime?instead of aString?.Article.title,Article.urlandSource.nameare now non-nullableString.- Errors are now thrown as
NewsApiException(implementsException) instead ofApiError. NewsAPIcan no longer be constructed directly. Configure it once viaNewsAPI.init()and access it anywhere viaNewsAPI.instance.
Added #
searchInparameter ongetEverything.NewsAPI.init()/NewsAPI.instancefor configuring and accessing a single shared instance.- Optional
client(for testing/caching/retrying) andtimeout(defaults to 30 seconds) onNewsAPI.init(). NewsAPI.close()to release the underlyinghttp.Client.- Validation that
sourcesisn't combined withcountry/categoryongetTopHeadlines.
Changed #
- Removed the
flutterSDK dependency; the package is now pure Dart. - Reorganized the package into
lib/srcwith a single public export file.
Fixed #
from/todates sent togetEverythingwere missing zero-padding (e.g.9instead of09), producing invalid timestamps.- A non-JSON response (e.g. an HTML error page from a proxy) threw an uncaught
FormatExceptioninstead of aNewsApiException.
1.2.1 #
- Internal improvements
1.2.0 #
- Internal improvements
1.1.1 #
- Internal improvements
1.1.0 #
- Null safety migration
1.0.1 #
- Update documentation.
1.0.0 #
- Implemented top headlines, everything, sources.