Mvvm

A Flutter MVVM (Model-View-ViewModel) implementation. It uses property-based data binding to establish a connection between the ViewModel and the View, and drives the View changes through the ViewModel.
Alternatives To Mvvm
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Mvvmlight1,683
6 years ago14Java
A toolkit help to build Android MVVM Application
Neutronium1,316383 months ago16September 11, 202092mitC#
🚀 Build .NET desktop applications using HTML, CSS and javascript.
Android Data Binding Recyclerview572
5 years ago10apache-2.0Java
Using Recyclerview with the new Android Data Binding framework
Android Mvvm437
5 years ago16apache-2.0Java
MVVM on Android using RxJava and Data Binding
Rxviewmodel370
93 years ago24October 31, 20179mitSwift
ReactiveViewModel-esque using RxSwift
Mvvmcross Samples328
a month ago33ms-plC#
Tutorials and samples for MvvmCross: The .NET MVVM framework for cross-platform solutions.
Android Viewmodelbinding312
5 years ago7Java
A lightweight library aiming to speed up Android app development by leveraging the new Android Data Binding together with the Model-View-ViewModel design pattern.
Tictactoe Mvvm238
4 years ago1Java
Sample android application used to learn the Model View View Model pattern and DataBinding in Android
Todolist Mvvm230
6 years ago3mitSwift
Sample application using MVVM in Swift
Mv2m186
7 years ago1apache-2.0Java
Android MVVM lightweight library based on Android Data Binding
Alternatives To Mvvm
Select To Compare


Alternative Project Comparisons
Readme

pub package

A Flutter MVVM (Model-View-ViewModel) implementation. It uses property-based data binding to establish a connection between the ViewModel and the View, and drives the View changes through the ViewModel.

一个 Flutter 的 MVVM(Model-View-ViewModel) 实现。 它使用基于属性 (property) 的数据绑定在视图模型 (ViewModel) 与视图 (View) 之间建立关联,并通过视图模型 (ViewModel) 驱动视图 (View) 变化。

import 'package:flutter/material.dart';
import 'package:mvvm/mvvm.dart';

/// ViewModel
class MyHomePageViewModel extends ViewModel {
  final timer$ = BindableProperty.$tick(
      duration: const Duration(milliseconds: 10), autostart: true, initial: 0);

  @override
  init() {
    registerProperty(#counter, BindableProperty.$value(initial: 0));
  }

  void incrementCounter() {
    updateValue<int>(#counter, (value) => value + 1);
  }
}

/// View
class MyHomePage extends View<MyHomePageViewModel> {
  final String title;
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  @override
  MyHomePageViewModel createViewModel() => MyHomePageViewModel();

  pad(int value) => '$value'.padLeft(2, '0');

  @override
  Widget build(BuildContext context, MyHomePageViewModel model) {    
    return Scaffold(
        appBar: AppBar(title: Text(title)),
        body: Center(
            child:
                Column(mainAxisAlignment: MainAxisAlignment.center, children: [
          $watch<int>(model.timer$,
              builder: (context, value, child) =>
                  Text('${pad(value ~/ 100)}.${pad(value % 100)}')),
          const Text('You have pushed the button this many times:'),
          model.$watchFor<int>(#counter,
              builder: (context, value, child) =>
                  Text('$value', style: Theme.of(context).textTheme.headline4))
        ])),
        floatingActionButton: FloatingActionButton(
            onPressed: model.incrementCounter,
            tooltip: 'Increment',
            child: const Icon(Icons.add)));
  }
}

/// run
void main() => runApp(MaterialApp(
      title: 'Flutter MVVM Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter MVVM Demo Home Page'),
    ));

Examples

APIs

Documentation

BindableProperty

  • $value
  • $adaptive
  • $async
  • $custom
  • $periodic
  • $tick
  • $merge
  • $mergeMap
  • $transform
  • $filter

WidgetBuilder

  • $watch
  • $watchFor
  • $any
  • $anyFor
  • $anyMap
  • $anyMapFor
  • $cond
  • $condFor
  • $if
  • $ifFor
  • $switch
  • $switchFor
  • $select
  • $build

ViewModel

  • registerProperty
  • getProperty
  • requireProperty
  • getPropertyOf
  • requirePropertyOf
  • getProperties
  • requireProperties
  • getValue
  • requireValue
  • setValue
  • setValues
  • updateValue
  • notify

View

  • createViewModel
  • build
  • didChangeDependencies
  • activate
  • deactivate
  • didUpdateWidget

ViewBuildContext

  • setState
  • model

License

MIT

Popular Viewmodel Projects
Popular Bindings Projects
Popular Software Architecture Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Dart
Flutter
Bindings
Mvvm
Viewmodel
State Management