mvc_pattern 3.4.1

mvc_pattern #

Build Status flutter and mvc

The "Kiss" of Flutter Frameworks #

In keeping with the "KISS Principle", this is an attempt to offer the MVC design pattern to Flutter in an intrinsic fashion incorporating much of the Flutter framework itself. All in a standalone Flutter Package.

Usage Let’s demonstrate its usage with the ol’ ‘Counter app’ created every time you start a new Flutter project. In the example below, to utilize the package, three things are changed in the Counter app. The Class, _MyHomePageState, is extended with the Class StateMVC, a ‘Controller’ Class is introduced. It extends the Class, ControllerMVC, and a static instance of that Class is made available to the build() function. Done! (Note, you will find the 'source code' for this example in this package's test folder.

With that, there's now a separation of ‘the Interface’ and ‘the data’ as intended with the MVC architecture. The build() function serves as 'the View.' It's concerned solely with the ‘look and feel’ of the app’s interface—‘how’ things are displayed. While it is the Controller that determines 'what’ is displayed. The Controller is also concerned with 'how' the app interacts with the user, and so it's involved in the app's event handling.

What data does the View display? It doesn’t know nor does it care! It ‘talks to’ the Controller instead. Again, it is the Controller that determines ‘what’ data the View displays. In this example, it’s a title and a counter. And when a button is pressed, the View again ‘talks to’ the Controller to address the event (i.e. calls one of the Controller’s public functions, incrementCounter()). myhomepage In this arrangement, the Controller is ‘talking back’ to the View by calling the View’s function, setState(), telling it to rebuild the widget tree.

viewandcontroller

Maybe we don’t want that. Maybe we want the View to be solely concern with the interface and solely determine when to rebuild the widget tree or not. It’s a simple change. myhomepage2 The View knows how to 'talk to' the Controller, but the Controller doesn't need to know how to 'talk to' the View. Notice what I did to the Controller? Makes the API between the View and the Controller a little clearer.

view talks to contoller only

It does separate the ‘roles of responsibility’ a little more, doesn’t it? After all, it is the View that’s concerned with the interface. It would know best when to rebuild, no? Regardless, with this package, such things are left to the developer. Lastly, notice how I created a static String field in the MyApp class called, title. It’s named ‘MyApp’ after all—It should know its own title.

myapp You see in the 'App' class above, that the Controller is instantiated in the parent class. Doing so allows your Controller to now access the many 'events' fired in a typical Flutter app.

How about Model?

Currently, in this example, it’s the Controller that’s containing all the ‘business logic’ for the application. In some MVC implementations, it’s the Model that contains the business rules for the application. So how would that look? Well, it maybe could look like this: howaboutmodel The Model’s API is also a little cleaner with the use of a static members. The View doesn’t even know the Model exists. It doesn’t need to. It still ‘talks to’ the Controller, but it is now the Model that has all the ‘brains.’

Note above, it's a full screenshot of the counter app example, and there's further changes made compared to the previous examples. Note, the State object again extends StateMVC and the 'MyApp' class is returned to StatelessWidget. Allows the State object to address events instead. Here, the Controller is passed to its parent class to 'plug it into' the event handling of a typical Flutter Widget. Finally, note the Controller's property and function names have been changed. This merely demonstrates that there's no 'hard cold rules' about what the API is between the View, the Controller, and the Model. You merely need to be consistent so they can 'talk to' each other.

pac pattern

However, what if you want the View to talk to the Model? Maybe because the Model has zillions of functions, and you don’t want the Controller there merely ‘to relay’ the Model’s functions and properties over to the View. You could simply provide the Model to the View. The View can then call the Controller's properties and functions as well the Model’s.

viewcantalk viewtomodel Not particularly pretty. I mean, at this point, you don't even need 'the Controller', but it merely demonstrates the possibilities. With this MVC implementation, you have options, and developers love options.

viewcontrollermodel

Below, I've changed it a little bit. The View still has access to the Model, but the Controller is still responsible for any 'event handling' and responds to the user pressing that lone button in the app. viewtomodel2

The Counter App #

Below is the Counter App you can copy n' paste to quickly try out:

import 'package:flutter/material.dart';

import 'package:mvc_pattern/mvc_pattern.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}
class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  // Fields in a Widget subclass are always marked "final".

  static final String title = 'Flutter Demo Home Page';

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {

  final Controller _con = Controller.con;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              widget.title,
            ),
            Text(
              '${_con.counter}',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(
              _con.incrementCounter
          );
        },
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
class Controller extends ControllerMVC {
  /// Singleton Factory
  factory Controller() {
    if (_this == null) _this = Controller._();
    return _this;
  }
  static Controller _this;

  Controller._();

  /// Allow for easy access to 'the Controller' throughout the application.
  static Controller get con => _this;

  int get counter => _counter;
  int _counter = 0;
  void incrementCounter() => _counter++;
}

Now you can easily introduce a Model:

class Controller extends ControllerMVC {
  factory Controller() {
    if (_this == null) _this = Controller._();
    return _this;
  }
  static Controller _this;

  Controller._();

  /// Allow for easy access to 'the Controller' throughout the application.
  static Controller get con => _this;

  int get counter => Model.counter;
  void incrementCounter() {
    /// The Controller knows how to 'talk to' the Model. It knows the name, but Model does the work.
    Model._incrementCounter();
  }
}
class Model {
  static int get counter => _counter;
  static int _counter = 0;
  static int _incrementCounter() => ++_counter;
}

Of course, you're free to 'switch out' variations of the Controller over time. In this case, you no longer need to assign a local variable, _con, but instead use a static reference: Controller.incrementCounter;

class Controller extends ControllerMVC {
  static int get counter => Model.counter;
  static void incrementCounter() => Model._incrementCounter();
}

Your First Flutter App: startup_namer #

This is the application offered in the website, Write Your First Flutter App, when you're first learning Flutter. This version has this MVC implementation.

MyApp.dart #

import 'package:flutter/material.dart';

import 'package:mvc_pattern/mvc_pattern.dart';

void main() => runApp(MyApp());

class MyApp extends AppMVC {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Startup Name Generator',
      theme: ThemeData(
        primaryColor: Colors.white,
      ),
      home: RandomWords(),
    );
  }
}

StateView #

Note the two classes below. RandomWords is extended by the StatefulWidgetMVC and the other, RandomWordsState, extended by StateMVC. With the class, RandomWords, the super constructor is passed the 'State Object', RandomWordsState (StateMVC). In turn, the State Object takes in the Controller Class, Con.

RandomWords.dart #

import 'package:mvc_pattern/mvc_pattern.dart';

class RandomWords extends StatefulWidgetMVC {
  RandomWords() : super(RandomWordsState(Con()));
}

class RandomWordsState extends StateMVC<RandomWords> {
  RandomWordsState(Con con) : super(con);

  final TextStyle _biggerFont = const TextStyle(fontSize: 18.0);

  @override

  /// the View
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Startup Name Generator'),
        actions: <Widget>[
          IconButton(
              icon: const Icon(Icons.list),
              onPressed: () {
                pushSaved(context);
              }),
        ],
      ),
      body: _buildSuggestions(),
    );
  }

  Widget _buildSuggestions() {
    return ListView.builder(
      padding: const EdgeInsets.all(16.0),
      // The itemBuilder callback is called once per suggested word pairing,
      // and places each suggestion into a ListTile row.
      // For even rows, the function adds a ListTile row for the word pairing.
      // For odd rows, the function adds a Divider widget to visually
      // separate the entries. Note that the divider may be difficult
      // to see on smaller devices.
      itemBuilder: (context, i) {
        // Add a one-pixel-high divider widget before each row in theListView.
        if (i.isOdd) return Divider();

        // The syntax "i ~/ 2" divides i by 2 and returns an integer result.
        // For example: 1, 2, 3, 4, 5 becomes 0, 1, 1, 2, 2.
        // This calculates the actual number of word pairings in the ListView,
        // minus the divider widgets.
        final index = i ~/ 2;
        // If you've reached the end of the available word pairings...
        if (index >= Con.length) {
          // ...then generate 10 more and add them to the suggestions list.
          Con.addAll(10);
        }
        return buildRow(index);
      },
    );
  }

  void pushSaved(BuildContext context) {
    Navigator.of(context).push(
      MaterialPageRoute<void>(
        builder: (BuildContext context) {
          final Iterable<ListTile> tiles = this.tiles;

          final List<Widget> divided = ListTile.divideTiles(
            context: context,
            tiles: tiles,
          ).toList();

          return Scaffold(
            appBar: AppBar(
              title: const Text('Saved Suggestions'),
            ),
            body: ListView(children: divided),
          );
        },
      ),
    );
  }

  Widget buildRow(int index) {
    if (index == null && index < 0) index = 0;

    String something = Con.something(index);

    final alreadySaved = Con.contains(something);

    return ListTile(
      title: Text(
        something,
        style: _biggerFont,
      ),
      trailing: Icon(
        alreadySaved ? Icons.favorite : Icons.favorite_border,
        color: alreadySaved ? Colors.red : null,
      ),
      onTap: () {
        setState(() {
          Con.somethingHappens(something);
        });
      },
    );
  }

  Iterable<ListTile> get tiles => Con.mapHappens(
        (String something) {
          return ListTile(
            title: Text(
              something,
              style: _biggerFont,
            ),
          );
        },
      );
}

Controller.dart #

Note how its all made up of static members and turns to Model for all the data.

import 'package:mvc_pattern/mvc_pattern.dart';

class Con extends ControllerMVC {
  static int get length => Model.length;

  static void addAll(int count) => Model.addAll(count);

  static String something(int index) => Model.wordPair(index);

  static bool contains(String something) => Model.contains(something);

  static void somethingHappens(String something) => Model.save(something);

  static Iterable<ListTile> mapHappens<ListTile>(Function f) => Model.saved(f);
}

Model.dart #

This Model works with the third-party library, english_words. The rest of the application has no idea. The Model is solely concern with where the 'words' originate from.

import 'package:english_words/english_words.dart';

class Model {
  static final List<String> _suggestions = [];
  static int get length => _suggestions.length;

  static String wordPair(int index) {
    if (index == null || index < 0) index = 0;
    return _suggestions[index];
  }

  static bool contains(String pair) {
    if (pair == null || pair.isEmpty) return false;
    return _saved.contains(pair);
  }

  static final Set<String> _saved = Set();

  static void save(String pair) {
    if (pair == null || pair.isEmpty) return;
    final alreadySaved = contains(pair);
    if (alreadySaved) {
      _saved.remove(pair);
    } else {
      _saved.add(pair);
    }
  }

  static Iterable<ListTile> saved<ListTile>(Function f) => _saved.map(f);

  static Iterable<String> wordPairs([int count = 10]) => makeWordPairs(count);

  static void addAll(int count) {
    _suggestions.addAll(wordPairs(count));
  }
}

Iterable<String> makeWordPairs(int count) {
  return generateWordPairs().take(count).map((pair){return pair.asPascalCase;});
}

Further information on the MVC package can be found in the article, ‘Flutter + MVC at Last!’ online article

Repository (GitHub)

API Docs

3.4.1 #

  • Flutter upgrade
  • _rebuildAllowed = true; after super.deactivate(); super.didUpdateWidget(oldWidget); super.reassemble();

3.4.0 #

July 02, 2019

  • of() function introduced.
  • expect() functions in mvc_pattern_test.dart

3.3.8 #

June 28, 2019

  • Bug fix _rebuildAllowed = true; in StateMVC.deactivate()

3.3.7 #

May 11, 2019

  • StateMVC.dispose() will only run once. Removed if(_disposed) return;

3.3.6 #

Apr. 21, 2019

  • Ensure StateMVC.dispose() is runs only once. if(_disposed) return;

3.3.5 #

Apr. 12, 2019

  • Return _rebuildAllowed = true; in didUpdateWidget() & reassemble()

3.3.4 #

Apr. 03, 2019

  • Correction Controllers and Listeners dispose calls in the StateMVC were not an issue after all.

3.3.3 #

Apr. 02, 2019

  • Call _disposeState() on all controllers when StateMVC is disposed.

3.3.2 #

Apr. 02, 2019

  • Proven prudent to not dispose any Controllers or Listeners in the StateMVC.

3.3.1 #

Apr. 02, 2019

  • ControllerMVC getter 'states' returns a 'copy' of the Set of State objects.
  • Only dispose a Controller if no longer relied on by a view.

3.3.0 #

Mar. 16, 2019.

  • Removed abstract from class ControllerMVC
  • Add didPopRoute() didPushRoute() to StateListener

3.2.4 #

Mar. 02, 2019.

  • No 'setState()' function is necessary; in some events.

3.2.3 #

Feb. 20, 2019.

  • await (con as AppConMVC)?.init();

3.2.2 #

Feb. 17, 2019.

  • _oldOnError = _recOnError()

3.2.1 #

Feb. 06, 2019.

  • Update the upper bound of the SDK constraint to <3.0.0

3.2.0 #

Jan. 30, 2019.

  • Deprecated Error Handler from Controller. Removed refresh(); from initState() & deactiveate

3.1.0 #

Jan. 26, 2019.

  • StateViewMVC implements StateListener & get controller

3.0.0 #

Jan. 25, 2019.

  • Changed class StateListener to a mixin
  • addState() in Controller and Listener adding any number of Views
  • abstract class StateViewMVC
  • class ViewMVC extends _StateObserver with _ControllerListing
  • void didChangeDependencies() will not refresh() on first build
  • Removed from Controllers the getters: widget, context, mounted
  • stateView getter is deprecated. Replaced by stateMVC. Removed stateMVC setter.
  • Removed controller setter in class ViewMVC
  • if (con is AppConMVC) //bool addBeforeListener(StateListener listener)

2.0.2 #

Jan. 19, 2019.

  • void addState(StateMVC state) {

2.0.1 #

Jan. 16, 2019.

  • AppMVC({this.con, Key key}) : super(key: key);

2.0.0 #

Jan. 16, 2019.

  • ControllerMVC(State state)
  • class _StateView with StateListener
  • _StateView() : _oldOnError = _recOnError() {
  • abstract class StateMVC
  • remove setter, controller
  • _StateListener.disposeStateEventList() use clear();
  • Removed StatefulWidgetMVC
  • Removed StatedWidget
  • abstract class AppMVC extends StatefulWidget {
  • Removed StatelessWidgetMVC

1.3.6 #

Jan. 12, 2019.

  • StateListener to replace StateEvents. addState() disposedState()

1.3.5 #

Jan. 11, 2019.

  • remove StateListener

1.3.4 #

Jan. 11, 2019.

  • StateListener as a mixin for StateEvents

1.3.3 #

Jan. 01, 2019.

  • Removed @protected from ViewMVC.build() Private _ControllerListing._con(String keyId)

1.3.2 #

Dec. 28, 2018.

  • if(mounted) in refresh()

1.3.1 #

Dec. 10, 2018.

  • sdk: ">=2.0.0 <5.0.0"

1.3.0 #

Dec. 03, 2018.

  • Updated README.md

1.3.0 #

Nov. 18, 2018.

  • add some further examples under test folder

1.2.4 #

Nov. 17, 2018.

  • fix on StateEvents assign on keyId

1.2.3 #

Nov. 13, 2018.

  • test for TestWidgetsFlutterBinding

1.2.2 #

Nov. 02, 2018.

  • fix on StatedWidget

1.2.1 #

Nov. 02, 2018.

  • fix on StateViewMVC

1.2.0 #

Oct. 29, 2018.

  • enhance AppMVC

1.1.1 #

Oct. 27, 2018.

  • StatefulWidgetMVC deemed deprecated

1.1.0 #

Oct. 25, 2018.

  • keyId in StateEvents

1.0.0 #

Oct. 24, 2018.

  • Official Production Release

0.0.14 #

Oct. 24, 2018.

  • fix on StateViewMVC & AppMVC & @protected

0.0.13 #

Oct. 23, 2018.

  • fix on _ControllerListing

0.0.12 #

Oct. 23, 2018.

  • class ViewMVC with _ControllerListing

0.0.11 #

Oct. 23, 2018.

  • class StateMVC with _ControllerListing, _StateEventList

0.0.10 #

Oct. 22, 2018.

  • include travis.yml

0.0.9 #

Oct. 21, 2018.

  • fix on ViewMVC & StateViewMVC

0.0.8 #

Oct. 20, 2018.

  • Updated the README.md

0.0.7 #

Oct. 19, 2018.

  • Provide example/main.dart

0.0.6 #

Oct. 18, 2018.

  • fix on StateMVC.con()

0.0.5 #

Oct. 18, 2018.

  • fix on StatedWidget

0.0.4 #

Oct. 18, 2018.

  • fix on StateMVC.add()

0.0.3 #

Oct. 18, 2018.

  • fix on AppMVC and StateEvents

0.0.1 #

Oct. 13, 2018.

  • Initial Release

example/lib/main.dart

/// Note: This license has also been called the "Simplified BSD License" and the "FreeBSD License".
/// See also the 2-clause BSD License.
///
/// Copyright 2018 www.andrioussolutions.com
///
/// Redistribution and use in source and binary forms, with or without modification,
/// are permitted provided that the following conditions are met:
///
/// 1. Redistributions of source code must retain the above copyright notice,
/// this list of conditions and the following disclaimer.
///
/// 2. Redistributions in binary form must reproduce the above copyright notice,
/// this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
///
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
/// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
/// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
/// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
/// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
/// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// To try this example,
/// Uncomment the import statement the line in the function, makeWordPairs(), below.
/// Of course, that means you'll have to modify your pubspec.yaml file.
//import 'package:english_words/english_words.dart';

import 'package:flutter/material.dart';

import 'package:mvc_pattern/mvc_pattern.dart';

void main() => runApp(MyApp());

class MyApp extends AppMVC {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Startup Name Generator',
      theme: ThemeData(
        primaryColor: Colors.white,
      ),
      home: RandomWords(),
    );
  }
}

class RandomWords extends StatefulWidget {
  @override
  State createState() => _RandomWordsState();
}

class _RandomWordsState extends StateMVC<RandomWords> {
  _RandomWordsState() : super(Con());

  final TextStyle _biggerFont = const TextStyle(fontSize: 18.0);

  @override

  /// the View
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Startup Name Generator'),
        actions: <Widget>[
          IconButton(
              icon: const Icon(Icons.list),
              onPressed: () {
                pushSaved(context);
              }),
        ],
      ),
      body: _buildSuggestions(),
    );
  }

  Widget _buildSuggestions() {
    return ListView.builder(
      padding: const EdgeInsets.all(16.0),
      // The itemBuilder callback is called once per suggested word pairing,
      // and places each suggestion into a ListTile row.
      // For even rows, the function adds a ListTile row for the word pairing.
      // For odd rows, the function adds a Divider widget to visually
      // separate the entries. Note that the divider may be difficult
      // to see on smaller devices.
      itemBuilder: (context, i) {
        // Add a one-pixel-high divider widget before each row in theListView.
        if (i.isOdd) return Divider();

        // The syntax "i ~/ 2" divides i by 2 and returns an integer result.
        // For example: 1, 2, 3, 4, 5 becomes 0, 1, 1, 2, 2.
        // This calculates the actual number of word pairings in the ListView,
        // minus the divider widgets.
        final index = i ~/ 2;
        // If you've reached the end of the available word pairings...
        if (index >= Con.length) {
          // ...then generate 10 more and add them to the suggestions list.
          Con.addAll(10);
        }
        return buildRow(index);
      },
    );
  }

  void pushSaved(BuildContext context) {
    Navigator.of(context).push(
      MaterialPageRoute<void>(
        builder: (BuildContext context) {
          final Iterable<ListTile> tiles = this.tiles;

          final List<Widget> divided = ListTile.divideTiles(
            context: context,
            tiles: tiles,
          ).toList();

          return Scaffold(
            appBar: AppBar(
              title: const Text('Saved Suggestions'),
            ),
            body: ListView(children: divided),
          );
        },
      ),
    );
  }

  Widget buildRow(int index) {
    if (index == null && index < 0) index = 0;

    String something = Con.something(index);

    final alreadySaved = Con.contains(something);

    return ListTile(
      title: Text(
        something,
        style: _biggerFont,
      ),
      trailing: Icon(
        alreadySaved ? Icons.favorite : Icons.favorite_border,
        color: alreadySaved ? Colors.red : null,
      ),
      onTap: () {
        setState(() {
          Con.somethingHappens(something);
        });
      },
    );
  }

  Iterable<ListTile> get tiles => Con.mapHappens(
        (String something) {
          return ListTile(
            title: Text(
              something,
              style: _biggerFont,
            ),
          );
        },
      );
}

class Con extends ControllerMVC {
  static int get length => Model.length;

  static void addAll(int count) => Model.addAll(count);

  static String something(int index) => Model.wordPair(index);

  static bool contains(String something) => Model.contains(something);

  static void somethingHappens(String something) => Model.save(something);

  static Iterable<ListTile> mapHappens<ListTile>(Function f) => Model.saved(f);
}

class Model {
  static final List<String> _suggestions = [];
  static int get length => _suggestions.length;

  static String wordPair(int index) {
    if (index == null || index < 0) index = 0;
    return _suggestions[index];
  }

  static bool contains(String pair) {
    if (pair == null || pair.isEmpty) return false;
    return _saved.contains(pair);
  }

  static final Set<String> _saved = Set();

  static void save(String pair) {
    if (pair == null || pair.isEmpty) return;
    final alreadySaved = contains(pair);
    if (alreadySaved) {
      _saved.remove(pair);
    } else {
      _saved.add(pair);
    }
  }

  static Iterable<ListTile> saved<ListTile>(Function f) => _saved.map(f);

  static Iterable<String> wordPairs([int count = 10]) => makeWordPairs(count);

  static void addAll(int count) {
    _suggestions.addAll(wordPairs(count));
  }
}

Iterable<String> makeWordPairs(int count) {
  /// Uncomment the import statement above and the line below to try this example.
  /// Of course, that means you'll have to modify your pubspec.yaml
//  return generateWordPairs().take(count).map((pair){return pair.asPascalCase;});
}

Use this package as a library

1. Depend on it

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


dependencies:
  mvc_pattern: ^3.4.1

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:mvc_pattern/mvc_pattern.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
94
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_test 0.0.0
Transitive dependencies
async 2.2.0 2.3.0
boolean_selector 1.0.4 1.0.5
charcode 1.1.2
collection 1.14.11 1.14.12
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.2 1.6.4
pedantic 1.7.0 1.8.0+1
quiver 2.0.3 2.0.5
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.4 1.0.5
term_glyph 1.1.0
test_api 0.2.5 0.2.7
typed_data 1.1.6
vector_math 2.0.8