News Application developed in Dart
Built with http requests and JSON classes and functions
A Flutter project that aims in developing an application that can fetch news data from the internet and display it in a proper format.
This Flutter application uses https
package to fetch data from the internet.
Documentation : [https] (https://pub.dev/packages/http)
The https
package has functions like get()
which can get data from the url specified.
The Provider package helps in updating/re-loading of resources whenever the main function is updated with data.
Documentation : [provider] (https://pub.dev/packages/provider)
ChangeNotifier
class has been used to provide change notification in the application where necessary.
This Flutter plugin helps to load urls either in browser or the application itself.
Documentation: [url_launcher] (https://pub.dev/packages/url_launcher)
The application has a few major sections:
-
lib
: contains the main files and resources of the application.a.
models
: containsnewsArticle
class that initializes JSON data into objects.b.
pages
: containsnewslist
class that serves as main UI of the application and receives data and displays it in proper format.c.
services
: containswebService
class that parses data from news API url, decodes received JSON body and then maps it to a list.d.
viewmodels
: containsnewsArticleListViewModel
andnewsArticleViewModel
classes that contain the model of the JSON data provided in the url and functions to return the data.e.
main.dart
: main class of the application that returns thenewslist
class. -
images
: contains thenewsDefault
image, that is displayed in case a news article fails to recieve any imageUrl. -
pubspec.yaml
conatains all the dependencies and assests required in the application.
The following website was used to generate an API key: News API Website
Abhinav Gupta
Thanks to all contributors and their support.