A Flutter project detailing how to build an application using TDD and clean architecture.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This application uses BLoC
. Providing you are using Clean Architecture in the intended manner, it ultimately doesn't matter what state management solution/framework you choose as you can easily swap one out for the other as you'll find below.
If you want to view a similar project that uses Riverpod
, please click here
There are a number of Flutter tutorials out there that illustrate how to build an application with different state management solutions such as BLoC
, GetX
, Riverpod
etc. However most are incomplete, they do not show how to integrate networking and make API calls or how tests can be written. In short, they do not provide an overall solution for clean architecture implementation. This project aims to give an insight into how you would create a production-level application that is scalable, testable and written with clean code.
- How to structure your application so that everything is modularised and discrete.
- How to write tests for every module of your application.
- How to structure your architecture in such a way that you can replace modules with different tools/libraries as you see fit. E.g. Replacing your
BLoC
state management with something likeRiverpod
.
There are certainly a number of ways that you can implementation your application such that you abide by the right design principles (SOLID, DRY, YAGNI etc.). However, there is no one approach that works better than the others. There is only those that are more modularised. Hence, the approach you should take depends on the project, its requirements and its constraints. For example, if you needed to create an MVP in a short amount of time you certainly wouldn't want to implement an architecture that conformed to TDD and was made of discrete components. You would want to use something that required little boiler-plate code and that should be developed quickly.
With that said, this approach here is not meant for MVP applications but rather for large-scale applications that require unit testing and components that aren't coupled together. I discuss in detail what the approach entails and how and why modules are organised and created in the fashion they are. You can read about it at the README here.
To get a local copy up and running follow these simple example steps.
- Follow the Flutter guide on Get Started to install the Flutter SDK on your machine. NOTE this project is built with Flutter version 2.8.0.
- Ensure everything is installed correctly by running the command
flutter doctor --verbose
on your terminal.
- Get a free API Key at News API.
- Clone the repo
git clone https://github.com/ajvelo/Flutter-News.git
- Install pub packages
flutter pub get
- Create a file in
lib/core/
calledconstants.dart
class Constants { static const apiKey = "YOUR-API-KEY"; }
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.