flutter_command 0.9.3 copy "flutter_command: ^0.9.3" to clipboard
flutter_command: ^0.9.3 copied to clipboard

outdated

flutter_command is a way to manage your state based on `ValueListenable` and the `Command` design pattern.

example/lib/main.dart

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

import 'homepage.dart';
import 'weather_viewmodel.dart';

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

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() {
    return MyAppState();
  }
}

class MyAppState extends State<MyApp> {
  WeatherViewModel viewModel;

  @override
  void initState() {
    viewModel = WeatherViewModel();

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return TheViewModel(
      theModel: viewModel,
      child: MaterialApp(title: 'Flutter Demo', home: HomePage()),
    );
  }
}

// InheritedWidgets allow you to propagate values down the widgettree.
// it can then be accessed by just writing  TheViewModel.of(context)
class TheViewModel extends InheritedWidget {
  final WeatherViewModel theModel;

  const TheViewModel({Key key, @required this.theModel, @required Widget child})
      : assert(theModel != null),
        assert(child != null),
        super(key: key, child: child);

  static WeatherViewModel of(BuildContext context) =>
      context.dependOnInheritedWidgetOfExactType<TheViewModel>().theModel;

  @override
  bool updateShouldNotify(TheViewModel oldWidget) =>
      theModel != oldWidget.theModel;
}
74
likes
0
pub points
81%
popularity

Publisher

unverified uploader

flutter_command is a way to manage your state based on `ValueListenable` and the `Command` design pattern.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, functional_listener, quiver_hashcode

More

Packages that depend on flutter_command