πŸš€ Sample Flutter Clean Architecture on Rorty App focused on the scalability, testability and maintainability written in Dart, following best practices using Flutter.

Overview

CodeStyle Flutter Dart License Apache 2.0

Rorty Flutter

Rorty πŸ“Ί (work-in-progress for V2 πŸ‘· πŸ”§οΈ πŸ‘·β€β™€οΈ ⛏ )

Getting Started

Flutter Clean Architecture in Rorty is a sample project that presents modern, approach to Flutter application development using Dart and latest tech-stack.

The goal of the project is to demonstrate best practices, provide a set of guidelines, and present modern Flutter application architecture that is modular, scalable, maintainable and testable. This application may look simple, but it has all of these small details that will set the rock-solid foundation of the larger app suitable for bigger teams and long application lifecycle management.

A flutter app built using Kotlin that consumes Rick and Morty API to display characters,episodes,Location from the TV Series. It has been built following Clean Architecture Principle, Repository Pattern, MVVM Architecture in the presentation layer.

Architecture

A well planned architecture is extremely important for an app to scale and all architectures have one common goal- to manage complexity of your app. This isn't something to be worried about in smaller apps however it may prove very useful when working on apps with longer development lifecycle and a bigger team.

Clean architecture was proposed by Robert C. Martin in 2012 in the Clean Code Blog and it follow the SOLID principle.

Clean Architecture

The circles represent different layers of your app. Note that:

  • The center circle is the most abstract, and the outer circle is the most concrete. This is called the Abstraction Principle. The Abstraction Principle specifies that inner circles should contain business logic, and outer circles should contain implementation details.

  • Another principle of Clean Architecture is the Dependency Inversion. This rule specifies that each circle can depend only on the nearest inward circle ie. low-level modules do not depend on high-level modules but the other way around.

Clean Architecture Diagram

Why Clean Architecture?

  • Loose coupling between the code - The code can easily be modified without affecting any or a large part of the app's codebase thus easier to scale the application later on.
  • Easier to test code.
  • Separation of Concern - Different modules have specific responsibilities making it easier for modification and maintenance.

S.O.L.I.D Principles

  • Single Responsibility: Each software component should have only one reason to change – one responsibility.

  • Open-Closed: You should be able to extend the behavior of a component, without breaking its usage, or modifying its extensions.

  • Liskov Substitution: If you have a class of one type, and any subclasses of that class, you should be able to represent the base class usage with the subclass, without breaking the app.

  • Interface Segregation: It’s better to have many smaller interfaces than a large one, to prevent the class from implementing the methods that it doesn’t need.

  • Dependency Inversion: Components should depend on abstractions rather than concrete implementations. Also higher level modules shouldn’t depend on lower level modules.

Layers

Project Structure

Project Structure

Data

The data layer is responsible for selecting the proper data source for the domain layer. It contains the implementations of the repositories declared in the domain layer.

Components of data layer include:

  • model

    -dto: Defines dto of ui model, also perform data transformation between domain, response and entity models.

    -local: Defines the schema of SQLite database.

    -remote: Defines POJO of network responses.

  • local: This is responsible for performing caching operations using Floor.

  • remote: This is responsible for performing network operations eg. defining API endpoints using Retrofit/Dio.

  • repository: Responsible for exposing data to the domain layer.

Domain

This is the core layer of the application. The domain layer is independent of any other layers thus ] domain business logic can be independent from other layers.This means that changes in other layers will have no effect on domain layer eg. screen UI (presentation layer) or changing database (data layer) will not result in any code change withing domain layer.

Components of domain layer include:

  • usecase: They enclose a single action, like getting data from a database or posting to a service. They use the repositories to resolve the action they are supposed to do.

Presentation

The presentation layer contains components involved in showing information to the user. The main part of this layer are the Views(widgets) and ViewModels.

Screenshots

Android

Splash Light Dark

iOS

Splash Light Dark

MacOS-Desktop

Light Dark

WEB

Light Dark

Tech Stacks

This project uses many of the popular libraries, plugins and tools of the flutter ecosystem.

  • Stacked - An architecture and widgets for an MVVM inspired architecture in Flutter.
  • Provider - A wrapper around InheritedWidget to make them easier to use and more reusable.
  • Get It - Dependency Injection library.
  • Retrofit - A dio client generator using source_gen and inspired by Chopper and Retrofit.
  • Dio - A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc.
  • Go Router - A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more.
  • Flutter Native Splash - Customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more.
  • Shared Preferences - Flutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.
  • Easy Localization - Easy and Fast internationalizing and localization your Flutter Apps.
  • Url Launcher - Flutter plugin for launching a URL. Supports web, phone, SMS, and email schemes.
  • Floor - The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications.
  • Logger - Small, easy to use and extensible logger which prints beautiful logs.

Code Analyze Tools

  • Lints - This package contains a recommended set of lints for Flutter apps, packages, and plugins to encourage good coding practices.

πŸš€ Posts In Medium

Article

🀝 Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Open an issue first to discuss what you would like to change.
  2. Fork the Project
  3. Create your feature branch (git checkout -b feature/amazing-feature)
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a pull request

Please make sure to update tests as appropriate.

✍️ Authors

πŸ‘€ developersancho

Linkedin Medium

Feel free to ping me πŸ˜‰

License

Copyright Β© 2022 - developersancho

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...

clean architecture and clean code with flutter , with bloc and getx state managment .

example_bloc A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Aug 22, 2022

Flutter Architecture inspired by Domain Driven Design, Onion and Clean Architecture

Flutter Architecture inspired by Domain Driven Design, Onion and Clean Architecture

Inspiring Domain Driven Design Flutter Architecture Please take a look at my slides to learn more Strategic Domain Driven Design For Improving Flutter

Dec 25, 2022

Proyect with Clean Architecture / Hexagonal Architecture - Patron BLoC - The MovieDB API

flutter_movies_db A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you starte

Sep 22, 2022

A Dart-native lightweight Apache Pulsar client primarily focused on the IoT telemetry domain

pulsar_iot_client A lightweight Apache Pulsar client primarily focused on the IoT telemetry domain. This project aims to improve the resulting perform

May 10, 2022

Starter-Flutter - Starter flutter project for best architecture and seperation of code

Starter-Flutter - Starter flutter project for best architecture and seperation of code

Modular-Architecture Codebase CodeBase , Infrastructure and the common Layers (c

Feb 16, 2022

A movies app made with Flutter focused on solid software structure patterns.

A movies app made with Flutter focused on solid software structure patterns.

Flutter Movies App An application made with Flutter to practice the principles of Clean Architecture. Even being focused on architecture, the project

Dec 12, 2022

A Launcher focused on simplicity and legibility.

  A Launcher focused on simplicity and legibility.

Elder Launcher Elder Launcher is a launcher designed for seniors focused on simplicity and legibility. Elder Launcher supports pinning favorite apps a

Dec 5, 2022

This is a set of small projects focused solely on the development of the graphical interface with Flutter

This is a set of small projects focused solely on the development of the graphical interface with Flutter

My Flutter Projects Flutter apps with cool design and animations Social Media Youtube Facebook Twitter Getting Started This project is a starting poin

Dec 19, 2022

Simple and complete Flutter hooks testing utilities that encourage good testing practices.

Simple and complete Flutter hooks testing utilities that encourage good testing practices.

Flutter Hooks Testing Library Simple and complete Flutter hooks testing utilities that encourage good testing practices. Inspired by react-hooks-testi

Dec 2, 2022
Owner
Mr.Sanchez
The Target is Red Apple =) Android & iOS | Kotlin | Flutter | Swift | KMM *** continue as long as we can. living in shadow ***
Mr.Sanchez
This is a repository for Flutter Focused Menu, an easy to implement package for adding Focused Long Press Menu to Flutter Applications

Focused Menu This is an easy to implement package for adding Focused Long Press Menu to Flutter Applications Current Features Add Focused Menu to Any

Paras Jain 160 Dec 26, 2022
🟧 Lints for Dart and Flutter based on software industry standards and best practices.

Solid Lints Flutter/Dart lints configuration based on software engineering industry standards (ISO/IEC, NIST) and best practices. Usage Add dependency

Solid Software 17 Oct 12, 2022
best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

Weekly Budget Flutter App A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Mohamed Awnallah 4 Oct 21, 2021
Flutter-clean-architecture - A simple flutter project developed with TDD and using Clean Architecture principles.

Clean Architecture This is a study project to practice TDD and a good approach of Clean Architecture for flutter projects. It is based on Reso Coder s

Luiz Paulo Franz 8 Jul 21, 2022
A Flutter Weather App primarily developed to showcase my technical knowledge as well as practices I believe are the best.

Weather One This is a Flutter Weather App primarily developed to showcase my technical knowledge as well as practices I believe are the best. The weat

Phumudzo Muvhango 1 Apr 27, 2022
Raden Saleh 20 Aug 12, 2023
Raden Saleh 53 Jul 27, 2023
Ouday 25 Dec 15, 2022
COVID-19 application made with Flutter, following Test Driven Development (TDD) and Clean Architecture along with Internationalization with JSON.

Covid App COVID-19 application made with Flutter, following Test Driven Development (TDD) and Clean Architecture along with Internationalization with

Sandip Pramanik 4 Aug 4, 2022
A sample project for following along a tutorial found on jap.alekhin.io.

Langaw Langaw is an endless tap game featured in the game development tutorial by Japa Alekhin Llemos in jap.alekhin.io. The tutorial series is split

Japa Alekhin Llemos 105 Oct 16, 2022