Skip to content

tech-ramakant/clean_architecture_sample

Repository files navigation

clean_architecture_sample

Hello there, fellow Flutter adventurers!

This repository contains the source code for the tutorial Clean Architecture in Flutter: Keeping Your Code Squeaky Clean! published on Medium. This code demonstrates how to apply Clean Architecture principles in Flutter, making your app structure more organized, testable, and scalable.

Table of Contents

Overview

As Flutter apps grow, a clean and scalable codebase becomes essential. This project introduces Clean Architecture to separate app layers and make the codebase easy to manage and extend. Each layer is independent, ensuring a separation of concerns that keeps code maintainable in the long run.

This is the accompanying code for my article that walks you through setting up Clean Architecture in Flutter, from understanding each layer to implementing it step-by-step.

Features

  • Clean Architecture: Separates code into data, domain, and presentation layers.
  • Repository Pattern: Makes it easy to swap out data sources or add new ones.
  • Scalable Structure: The app’s structure allows it to grow without sacrificing code quality.
  • Detailed Documentation: Code is documented for easy understanding with helpful comments.

Installation

  1. Clone the repository:

    git clone https://github.com/tech-ramakant/clean_architecture_sample.git
  2. Navigate to the project directory:

    cd clean_architecture_sample
  3. Install the dependencies:

    flutter pub get
  4. Run the app:

    flutter run

Usage

Explore the code in the lib/ folder to see how Clean Architecture principles are applied across the project layers. You can follow along with the steps in the Medium tutorial.

Example - Using a Use Case in Clean Architecture:

class GetCoffeeTypes {
  final CoffeeRepository repository;

  GetCoffeeTypes(this.repository);

  Future<List<Coffee>> call() async {
    return await repository.fetchCoffeeTypes();
  }
}

In this case, GetCoffeeTypes is a use case that gets coffee data via the CoffeeRepository without knowing where the data comes from (local or remote), keeping the code modular and testable.

Contributing

Feel free to open issues or make pull requests to improve this project. Contributions are always welcome!

Fork the repo

  • Create your branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any inquiries, feel free to reach out to me via:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published