An MVP framework for flutter applications

Related tags

Templates mvp_core
Overview

mvp_core

An MVP (model/view/presenter) framework for applications written in dart. This package gives specific support to the flutter framework.

Getting Started

The following code is a stubbed out tutorial of how to use this package. See the example directory in the repository of this package for a more complete example. You can find the repository here.

Create the presenter (and the interfaces it expects). I recommend placing these 3 classes in the same file because they are all closely related to eachother.

/// The interface the presenter will use to communicate with the view.
abstract class IMyView extends IView { ... }

/// The interface the view will use to communicate with the presenter.
abstract class IMyPresenter extends IPresenter { ... }

/// The concrete presenter which updates the view and the model.
class MyPresenter extends Presenter<IMyView> implements IMyPresenter { ... }

Create the view (using the interfaces the presenter expects). I again recommend placing these classes in the same file because they are closesly related to each other.

/// Since the presenter updates the view's state,
/// the view should be a [StatefulWidget].
class MyPage extends StatefulWidget {
    @override
    _MyPageState createState() => _MyPageState();
}

/// The concrete view which the presenter updates. The view depends 
/// on the presenter and implements the interfaces it expects
class _MyPageState extends StateView<MyPage, IMyPresenter> implements IMyView {

    /// Builds the UI for the view just like any
    /// other flutter stateful widget.
    @override
    Widget build(BuildContext context) { ... }

    /// Create the presenter which will update this view.
    ///
    /// This is the only place where the concrete presenter
    /// should be referenced in the view.
    @override
    IMyPresenter createPresenter() => MyPresenter();
}

Purpose

Weak coupling

This package attempts to create a weak coupling between views and presenters in flutter applications. This means that views only know about the interfaces of their associated presenters and presenters only know about the interfaces of their associated views.

Automated testing

Because of weak coupling, automatically testing an application becomes trivial. See Testing.

No assumptions about the model

This package makes no assumptions about the model of your application. This means that any model (or data) you choose (as well as whatever model pattern) will work with this framework.

Testing

"The MVP pattern is a variation of the MVC pattern that results in more testable code."

Since the coupling between the views and the presenters is strictly through interfaces, it's easy to create a MockView to test the presenter. See the example directory of this package's repository for and example of how to do this.

To test the widgets, you can simply perform the same widget-tests that you would perform in any other application.

You might also like...

This is an easy to use Flutter Package for adding Fancy Foldable Sidebar to your Flutter Applications.

This is an easy to use Flutter Package for adding Fancy Foldable Sidebar to your Flutter Applications.

Foldable Sidebar An easy to implement Foldable Sidebar Navigation Drawer for Flutter Applications. Current Features Initial Release for Foldable Navig

Nov 26, 2022

Flutter micro app - A package to speed up the creation of micro frontend(or independent features) structure in Flutter applications

Flutter micro app - A package to speed up the creation of micro frontend(or independent features) structure in Flutter applications

A package to speed up the creation of micro frontend(or independent features) st

Dec 22, 2022

CloseSea-Flutter - CloseSea is Flutter UI of OpenSea NFT's Applications

CloseSea-Flutter - CloseSea is Flutter UI of OpenSea NFT's Applications

flutter_closesea_nft Onboarding Page Home Page Font use in this App Concept : (f

Aug 31, 2022

Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications

Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications

Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications. We have redesigned all the usual components to make it look like our Now UI Design, minimalistic and easy to use.

Oct 9, 2022

This is tool to create 3D Models which can be used in Flutter Applications. Tool is developed completely using Flutter.

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

Nov 8, 2022

Build installers for your Flutter applications with Squirrel

squirrel A new Flutter package project. Getting Started This project is a starting point for a Dart package, a library module containing code that can

Dec 28, 2022

Flutter starter template for production applications with a REST backend

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

Apr 13, 2022

A fancy easy to use Folding Menu for Flutter Applications

A fancy easy to use Folding Menu for Flutter Applications

Folding Menu This is an easy to use package for adding Folding Menu to your Flutter Applications Demo Usage To Use, simply add Folding Menu to your St

Nov 26, 2022
Comments
  • Failing to run

    Failing to run

    Hello, I would like to use your library but it fails to run. Reason is here

    @override
      void didUpdateWidget(T oldWidget) {
        super.didUpdateWidget(oldWidget);
    
        if (!_initialized) {
          super.start();
          this._initialized = true;
        }
    
        super.update();
      }
    

    it crashes on if(_initailized) check because _initialized is privat variable and is null. You have to use public variable instead becuase public has ?? check.

    opened by vytautas-pranskunas- 0
Owner
Josiah Saunders
I build software.
Josiah Saunders
This repository show you how apply MVP to Flutter project

Flutter MVP demo Apply MVP to Flutter project. To easy understand this project, you can visit my other project first which talk about ListView on Flut

Yen Dang 4 Oct 26, 2020
O Invest App é um aplicativo de plataforma de investimento feito em FLutter para encontrar, rastrear e proteger seus investimentos. É um MVP aberto para estudo e portfólio.

Invest App Tópicos Descrição do projeto Funcionalidades Aplicação Ferramentas utilizadas Acesso ao projeto Abrir e rodar o projeto Descrição do projet

Nícolas Bruno Morais 2 Oct 24, 2022
This is a MVP our app's. The app get the song's list on firebase and display then you can be listen App features.

music_app Requirements: flutter version 3.0.3 Dart 2.17.5 Firebase CLI 11.1.0 flutter sdk: >= 2.15.1 < 3.0.0 flutter dependentcies: http: 0.13.4 mvvm:

Lê Hồng Minh 3 Aug 2, 2022
A comprehensive guide on learning how to code cross platform mobile applications with the Flutter framework, from the ground up.

✳️ The Ultimate Guide to App Development with Flutter ✳️ A complete and comprehensive guide to learning Flutter with explanations, screenshots, tips,

Anthony 243 Jan 1, 2023
Arna Framework - A unique set of widgets for building applications with Flutter.

Arna Arna Framework - A unique set of widgets for building applications with Flutter. This Framework is in active development. Any contribution, idea,

Mahan 86 Dec 11, 2022
Dartness is a progressive dart framework for building efficient and scalable server-side applications

Dartness is a framework for building efficient, scalable dart server-side applications. It provides an easy and quick way to develop modern standalone server.

Ricardo Romero 33 Dec 12, 2022
🦜 Parrot - A progressive Dart framework for building efficient, reliable and scalable server-side applications.

?? Parrot A progressive Dart framework for building efficient, reliable and scalable server-side applications. What is Parrot? Parrot is a Dart framew

Odroe 8 Nov 11, 2022
Intel Corporation 238 Dec 24, 2022
The ROHD Verification Framework is a hardware verification framework built upon ROHD for building testbenches.

ROHD Verification Framework The ROHD Verification Framework (ROHD-VF) is a verification framework built upon the Rapid Open Hardware Development (ROHD

Intel Corporation 18 Dec 20, 2022
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