santiracca / masterclass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter Masterclass

Introduction

This project serves as a demo to showcase some key features to make flutter development an incredible experience

Table of Contents

  • Arquitecture
  • Testing
  • Native
  • Configuration
  • Libraries

Arquitecture

We follow a clean arquitecture approach that enforces seperation of concerns. This allows our code to be more readable, testable and less error-prone. Our own custom approach to the arquitecture is to have three main layers.

Presentation

This layer holds all the logic related to the UI. It has little to no business logic and primarily serves to display views and widgets to the user and receive user interaction. By keeping this layer free from all business logic, we can safely work on UI design and not have to worry about breaking functionality. Additionaly, this also has the benefit of making the views and widgets relatively lean, thus further enhancing readability.

This layer also holds our state controllers. These controllers focus on reducing state and making calls to either a usecase or a repository.

Domain

This layer is where the main business logic of the application resides, it is the "meat" of the app. The layer is primary split into models, repositories and use cases.

  • Models: Holds the bussiness entities of the application
  • Repositories: Holds the abstract class that specify what a repository implementation must fullfill. By keeping the abstraction in this layer, we can improve testability.
  • Usecases: Usecases are where application specific business logic is performed. These usecases are single responsibility classes that allow our business logic to be seperated from the flutter framework.

Data

This layer holds the repository implementations and primarily focuses on making database and API requests. By seperating this layer from the business logic, we can achieve tremendous independency from specific database and API providers, making transitions to different providers relatively easy.


Testing

Unit Tests

Flutter Unit Test Documentation

Integration Tests

In flutter, Integration testing erroneusly refers to E2E Testing. It is important to understand the difference to avoid confusion

E2E Testing

Flutter Integration Testing Documentation

Flutter Integration Testing with Firebase Test Lab
NOTES

Static methods in flutter cannot be mocked, if you need to mock a static method then create a wrapper class around the library.


Features

Factory Constructors

Dart Constructors

Factory constructors are very useful to deserialize data coming from a server into a model. Additionally they provide other useful usecases

Generics

Dart Generics Documentation

Generics in dart allow us to create composable classes and functions in order to achieve improved type safety as well as avoid code duplication.

Extensions

Dart Extension Methods

Extension methods allow us to add functionality to existing libraries such as adding a custom method on the String class for custom formatting.

Mixins

Dart Mixins

Mixins allow to reuse class functionality without having to extend from a base class. Dart only allows extending one base class.

Callable Classes

Dart Callable Classes

Implementing the call method in a class allows us to call a class like a function

Native

Method Channels

Method Channel Documentation

Event Channels

Flutter Event Channels


Libraries

GENERAL

SUGGESTED

State Management

Navigation, Snackbars and Dialog

About


Languages

Language:Dart 56.0%Language:HTML 38.1%Language:Swift 4.2%Language:Kotlin 1.3%Language:Objective-C 0.4%