Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 10 13:45

    unicreators on dev

    v 0.3.0 * 增加在视图 `View` 中创建属性功能… (compare)

  • Jan 01 11:53
    unicreators closed #15
  • Jan 01 11:53
    unicreators commented #15
  • Jan 01 11:48

    unicreators on master

    1. Null safety support 1. Null safety support 1. Null safety support and 1 more (compare)

  • Jan 01 11:44

    unicreators on dev

    1. Null safety support (compare)

  • Jan 01 09:52

    unicreators on dev

    1. Null safety support (compare)

  • Jan 01 09:49

    unicreators on dev

    1. Null safety support (compare)

  • Jul 01 2021 10:58
    Rubywai opened #15
  • Mar 06 2021 06:50

    unicreators on master

    1. 代码优化 Merge pull request #14 from uni… (compare)

  • Mar 06 2021 06:48

    unicreators on dev

    1. 代码优化 (compare)

  • Aug 21 2020 03:10
    kamike closed #11
  • Aug 21 2020 03:09
    kamike commented #11
  • Jul 21 2020 09:39
    kamike reopened #11
  • Jul 20 2020 06:11
    kamike closed #12
  • Jul 20 2020 06:11
    kamike closed #11
  • Jul 14 2020 08:33
    kamike closed #13
  • Jul 14 2020 08:22
    kamike opened #13
  • Jul 07 2020 02:12
    kamike commented #11
  • Jun 17 2020 02:56
    kamike opened #12
  • Jun 17 2020 02:46
    kamike commented #11
yichen
@unicreators

Flutter 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.

https://pub.dev/packages/mvvm

import 'package:flutter/widgets.dart';
import 'package:mvvm/mvvm.dart';
import 'dart:async';

// ViewModel
class Demo1ViewModel extends ViewModel {

  Demo1ViewModel() {
      // define bindable property
      propertyValue<String>(#time, initial: "");
      // timer
      start();
  }

  start() {
      Timer.periodic(const Duration(seconds: 1), (_) {
        var now = DateTime.now();
        // call setValue
        setValue<String>(#time, "${now.hour}:${now.minute}:${now.second}");
      });
  }
}

// View
class Demo1View extends View<Demo1ViewModel> {
  Demo1View() : super(Demo1ViewModel());

  @override
  Widget buildCore(BuildContext context) {
    return Container(
        margin: EdgeInsets.symmetric(vertical: 100),
        padding: EdgeInsets.all(40),

        // binding
        child: $.watchFor<String>(#time, 
            builder: $.builder1((t) => 
              Text(t, textDirection: TextDirection.ltr))));
  }
}

// run
void main() => runApp(Demo1View());
publish v0.1.4
Yosof
@kitesoft
thanks .greate job
do you plan to support flutter web?
Yosof
@kitesoft
it's work great with flutter web.thanks
image.png
some changes I made
image.png
yichen
@unicreators
cool! I haven't tried yet. good job!
publish v0.1.4+1
Yosof
@kitesoft
I have separate my widgets in Multiple Classes
and use them in a View that extends ViewModel
but i cant access "ViewModel" and "$.watchFor" from there.
need easy way like this : ViewModel<aViewModel>.of(ViewContext)
yichen
@unicreators
Get ViewModel instance in view?use "$Model" or "$.model"
yichen
@unicreators
publish v0.1.5+1