Structured and Organized Flutter (ANDROID+WEB) template project using Redux architecture and Retrofit rest package

Overview

flutter_redux_template

A new Flutter project.

JSON

Models classes need this lines to json generator:

part 'foo.g.dart'; //on imports

factory Foo.fromJson(Map<String, dynamic> json) => _$FooFromJson(json);
Map<String, dynamic> toJson() => _$FooToJson(this);

When model or api classes changes run:

flutter pub run build_runner build --delete-conflicting-outputs

Flutter Redux

React Views

  1. As a performance optimization, the Widget can be rebuilt only when the ViewModel changes. In order for this to work correctly, you must implement == and hashCode for the ViewModel, and set the distinct option to true when creating your StoreConnector.

  2. Use sample method fromStore to encapsulate store.state to viewModel transformation

@immutable
class _FooPageViewModel {
  final String foo;
  final Function dispatcher;

  const _FooPageViewModel(this.foo, this.dispatcher);

  static _FooPageViewModel fromStore(Store<AppState> store) {
    return _FooPageViewModel(store.state.foo, (action) => store.dispatch(action));
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is _FooPageViewModel &&
        other.foo == foo &&
        other.dispatcher == dispatcher;
  }

  @override
  int get hashCode {
    return foo.hashCode ^ dispatcher.hashCode;
  }
}

class FooPage extends StatelessWidget {
  const FooPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, _FooPageViewModel>(
      distinct: true,
      converter: (store) => _FooPageViewModel.fromStore(store),
      builder: (context, viewModel) {
        return Scaffold(
          body: TextButton(
            child: Text(viewModel.foo),
            onPressed: () => viewModel.dispatcher(FooAction()),
          )
        );
      },
    );
  }
}
You might also like...

Flutter-Movie - 😎 🎬 A Flutter movie app build with Fish-Redux and The Movie DB api.

Flutter-Movie - 😎 🎬 A Flutter movie app build with Fish-Redux and The Movie DB api.

movie A Flutter movie app build with Fish-Redux and TMDB api. ToDos redesign UI account detail customize stream support dark mode support localization

Dec 23, 2022

Flutter-Movie - A Flutter movie app build with Fish-Redux na TMDB api

Flutter-Movie - A Flutter movie app build with Fish-Redux na TMDB api

the applikation A Flutter movie app build with Fish-Redux na TMDB api. ToDos redesign UI account detail customize stream support dark mode support loc

Jul 21, 2022

Github Trending app built with Flutter+Redux+Built(Immutable Data)

Github Trending app built with Flutter+Redux+Built(Immutable Data)

May 13, 2020

Dart Web API Template Using Google Shelf Framework and Postgres Drivers, read readme to learn how to use

Shelf Web Framework Template by Alex Merced of AlexMercedCoder.com Cloning the Template git clone https://github.com/AlexMercedCoder/DartShelfPostgres

Dec 26, 2022

Software Developer Portfolio Template built using Dart, Flutter web

Dev Portfolio Software Developer Portfolio Template that helps you showcase your work and skills as a software developer. A lightweight, customizable

Dec 10, 2022

Flutter template project - Simple ToDo app with scalable project structure.

Flutter template project - Simple ToDo app with scalable project structure.

Flutter Template Flutter template project - A simple TODO list app. This template provides simple UI and scalable project structure that goes beyond t

Nov 21, 2022

WooCommerce App template that uses Flutter. Integrated to work with WooCommerce stores, connect and create an IOS and Android app from Flutter for IOS and Android

WooCommerce App template that uses Flutter. Integrated to work with WooCommerce stores, connect and create an IOS and Android app from Flutter for IOS and Android

WooCommerce App: Label StoreMax Label StoreMax - v5.3.1 Official WooSignal WooCommerce App About Label StoreMax Label StoreMax is an App Template for

Jan 9, 2023

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
Owner
Raul Abreu
Raul Abreu
Flutter getx template - A Flutter Template using GetX package for State management, routing and Dependency Injection

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package

Tareq Islam 6 Aug 27, 2022
Starting template for a new Flutter project. Using clean architecture + Riverpod.

flutter_project_template_riverpod Installation Add Flutter to your machine Open this project folder with Terminal/CMD Ensure there's no cache/build le

Bahri Rizaldi 39 Dec 27, 2022
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.

Flutter Architecture Blueprints Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to dev

Katsuyuki Mori 2 Apr 9, 2022
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.

Flutter Architecture Blueprints Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to dev

Daichi Furiya 1.5k Dec 31, 2022
Flutter starter template for production applications with a REST backend

Flutter Boilerplate My Flutter starter template for production applications with a REST backend. The main aim of this template is to get you up and ru

Ali Behzadian Nejad 3 Apr 13, 2022
Flutter project template with BloC architecture. Implemented many feature as stated in README

Flutter Project Template Using BloC Implementations Theme switching Advanced Routing Bloc Observer for debugging Hydrated Cubit for holding value even

Baran Açıkgöz 9 Dec 10, 2022
Clean architecture template project for new flutter applications.

clean_template Clean architecture template project for new flutter applications. Implemented app logic RestClient - rest API client-server networking

mentally_unstable 3 Jul 27, 2022
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
meg4cyberc4t 11 Oct 24, 2022
Ouday 25 Dec 15, 2022