Coder Social home page Coder Social logo

countriesapp's Introduction

Project Overview ๐Ÿ˜ƒ

This is a country informative app built with flutter, it consumes an API from which data is gotten from, a list of country data with some information like population, capital, language, currency and other is displayed in the Country detail screen. The app supports both light and dark theme, with multiple languages

Getting Started ๐Ÿš€

This project contains only 1 flavor:

  • development

To run development either use the launch configuration in VSCode/Android Studio or use the following commands:

# Development
$ flutter run --target lib/main.dart

CodeBase ๐Ÿค–

The projects code base is structured in resemblance to clean architecture but not as detailed. With the initiative to make the app easily extensible, everything basically everything was abstracted and Single responsibility was put into mind to achieve this, also used provider sor statemanage management and a little bit of dependency injection. The project has 6 folders under the lib directory /lib, which are core,domain,model,provider,screens and services with each folder containing a file having a particular responsibility. I have a datasource file in the service folder where i made my network call, i have a network folder in the core folder which has an api_requester file where i instantiated my dio package and configured it with the base_url, the network folder also have a network file where i checked for internet connectivity using the InternetConnectionChecker package. Also, it has an error folder still in the core folder where i managed every possible errors, the error folder in turn has an error file and a failure file. In both of these files i handeled errors and failures such as NoInternetFailure, TimoutFailure, NoDataFailure and others. i also have a constants folder where i created the base_url. The provider folder contains my provider class, the screens folder contains the app screens and a widget folder of some widgets i abstracted.

lib
โ”œโ”€โ”€ core
โ”‚   โ”œ-----constants
โ”‚   โ”‚      โ”œโ”€โ”€ network_client.dart
โ”‚   โ”‚
|   |-----di
โ”‚   |     โ”œโ”€โ”€ di_container.dart
โ”‚   โ”‚     โ””โ”€โ”€ di.container.config.dart
โ”‚   โ”‚     โ””โ”€โ”€ register_module.dart
โ”‚   โ”‚
โ”‚   โ”‚-----errors
โ”‚   |     โ”œโ”€โ”€ error.dart
โ”‚   โ”‚     โ””โ”€โ”€ failure.dart
โ”‚   โ”‚
โ”‚   โ”‚-----network
โ”‚   |     โ”œโ”€โ”€ api_requester.dart
โ”‚   โ”‚     โ””โ”€โ”€ network_info.dart
โ”‚   โ”‚
โ”‚   โ”‚-----Theme
โ”‚   |     โ”œโ”€โ”€ myTheme.dart
โ”‚   โ”‚     โ””โ”€โ”€ response.dart
โ”‚   โ”‚     โ””โ”€โ”€ theme_config.
โ”‚   โ”‚
โ”‚   โ”‚-----usecase
โ”‚   |     โ””โ”€โ”€  usecase.dart
โ”‚   โ”‚     
โ”‚   โ”‚-----widgets
โ”‚   |     โ””โ”€โ”€  appbar.dart
โ”‚   โ”‚ 
โ”‚   โ”‚ 
โ”œโ”€โ”€ domain  
โ”‚   โ”‚-----repository
โ”‚   |     โ”œโ”€โ”€ country_repository.dart
โ”‚   โ”‚     โ””โ”€โ”€ country_repository.dart
โ”‚   โ”‚ 
โ”‚   โ”‚-----usecase
โ”‚   |     โ””โ”€โ”€  fetch_countires_usecase.dart
โ”‚   โ”‚
โ”‚   โ”‚-----entity.dart
โ”‚   โ”‚ 
โ”‚   โ”‚
โ”œโ”€โ”€ model 
โ”‚   โ”‚-----(all models can be found here)
โ”‚   โ”‚
โ”‚   โ”‚
โ”œโ”€โ”€ provider
โ”‚   โ”‚-----country_notifier.dart
โ”‚   โ”‚
โ”‚   โ”‚
โ”œโ”€โ”€ screens
โ”‚   โ”‚-----details_screen.dart
โ”‚   โ”‚-----home.dart
โ”‚   โ”‚
โ”‚   โ”‚
โ”œโ”€โ”€ services
โ”‚   โ”‚-----data_source.dart

 

Libraries Used ๐Ÿ› ๏ธ

For this project i used a couple of libraries to achieve an easily extensible codebase and clean code writing. Here are some packages i used.

# Dio
  I usde Dio for network request
  
# internet_connection_checker
  A pure Dart library that checks for internet by opening a socket to a list of specified addresses, each with individual port and timeout

# json_annotation
  Classes and helper functions that support JSON code generation via the `json_serializable` package.
  
# equatable
  A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

# provider
  A wrapper around InheritedWidget to make them easier to use and more reusable.
  
# json_serializable
  Automatically generate code for converting to and from JSON by annotating Dart classes.
  
# injectable
  Injectable is a convenient code generator for get_it.
  
# get_it: ^7.2.0
  Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App

These some of the packages i used to achieve a clean code and structure

Challenges faced ๐Ÿ˜–

I faced a lot of challenges considering that i am not too good with some of these packages, i was getting an error using getIt that my classes arent registered when i had already registered, i spent a full day on this error, i wanted to give up but i persisted until i realized i had to run build runner build after manualling deleting the perviously generted .config file. Also, after i had created my model, i was getting an error like 'List is not a subtype of Map<Sting,dynamic>' it sounds like an easy error but i spent almost a whole day on it as well until i realised some of the field were not present in all maps so i had to make some nullable. so basically thats some of the challenges i faced.

Features i would like to add ๐Ÿ’ก

it would be nice if the app has like a couple of short videos on each country that shows a little bit on what the people of the country look like and their culture

Appetize Link ๐Ÿ“ฑ

https://appetize.io/app/zgio2uzodp77hggn56f5gcctqi?device=pixel4&osVersion=11.0&scale=75

countriesapp's People

Contributors

vershimakelvin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.