mvp_core 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new53

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 {
    _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.
    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.
    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.

[0.0.1] - March 21, 2020 #

  • Created the initial mvp framework layout.

[0.0.2] - March 21, 2020 #

  • Improved maintenance score


import 'package:flutter/material.dart';

import 'login/view.dart';

void main() {

/// Shows the login page
class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
      home: LoginPage(),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  mvp_core: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:mvp_core/mvp_core.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies