mvcprovider 2.0.4 copy "mvcprovider: ^2.0.4" to clipboard
mvcprovider: ^2.0.4 copied to clipboard

outdated

Write less & do more with the simplest syntax to implement an MVC pattern architecture in Flutter with the Provider package without a lot of boilerplate code.

example/README.md

mvcprovider #

Lean how to use Flutter with the mvcprovider package with a simple counter example or with a complete & ready to code scaffold.

Complete example - A ready to dev scaffolding #

Please follow this link to start creating value fast : The Flutter Scaffold by Mr#

In this project you will find homemade components, tools and services that can save you time by reusing (some of) them but it depends on your project :)

This complete example is designed to show you how to organize & handle :

- Logging IN/OUT
- Translations
- Http requests
- Cache data
- Cache request results
- Loading events
- Local Storage
- Theming
- Mocking data
- Routing between views/pages
- Securing routing (guards)
- Retrieving data from an api (Pixabay)
- Sliver animations (header app bar)
- Hero animations

Simple example - Simple Counter App #

Please follow this link to find the simple example : Simple example source code

Simple example : main.dart #

    import 'package:flutter/material.dart';
    import 'features/mycounter/my.counter.dart';
    
    void main() => runApp(AmazingSample());
    
    class AmazingSample extends StatelessWidget {
      // This widget is the root of this amazing package sample.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'MVC Provider counter demo',
          home: MyCounterModule(),
        );
      }
    }

Simple example : modules/mycounter/my.counter.dart #

    import 'package:mvcprovider/mvcprovider.dart';
    import 'my.counter.ctrl.dart';
    import 'my.counter.model.dart';
    import 'my.counter.view.dart';
    
    class MyCounterModule extends MVC_Module<MyCounterModel, MyCounterView, MyCounterCtrl> {
      final MyCounterModel model = MyCounterModel();
      final MyCounterView view = MyCounterView();
      final MyCounterCtrl ctrl = MyCounterCtrl();
    }

Simple example : modules/mycounter/my.counter.model.dart #

    import 'package:mvcprovider/mvcprovider.dart';
    import 'my.counter.ctrl.dart';
    
    class MyCounterModel extends MVC_Model<MyCounterCtrl> {
      int _count = 0;
      set count(int value) {
        _count = value;
        notifyListeners();
      }
      int get count => _count;
    }

Simple example : modules/mycounter/my.counter.ctrl.dart #

    import 'package:mvcprovider/mvcprovider.dart';
    import 'my.counter.model.dart';
    
    class MyCounterCtrl extends MVC_Controller<MyCounterModel> {
      void increment() {
        model.count++;
      }
    }

Simple example : modules/mycounter/my.counter.view.dart #

    import 'package:flutter/material.dart';
    import 'package:mvcprovider/mvcprovider.dart';
    import 'my.counter.ctrl.dart';
    import 'my.counter.model.dart';
    
    class MyCounterView extends StatelessWidget with MVC_View<MyCounterModel, MyCounterCtrl> {
      @override
      Widget build(BuildContext context, [Widget child]) {
        listen(context);
    
        return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text("Counter : ${model.count}"),
              RaisedButton(child: Text("Increment"), onPressed: ctrl.increment)
            ]
        );
      }
    }
7
likes
40
points
4
downloads

Publisher

verified publishermrdiez.com

Weekly Downloads

Write less & do more with the simplest syntax to implement an MVC pattern architecture in Flutter with the Provider package without a lot of boilerplate code.

Repository (GitLab)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter, provider

More

Packages that depend on mvcprovider