This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CounterApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return new ScopedModel<CounterModel>( | |
| model: new CounterModel(), | |
| child: new Column(children: [ | |
| new ScopedModelDescendant<CounterModel>( | |
| builder: (context, child, model) => new Text('${model.counter}'), | |
| ), | |
| new Text("Another widget that doesn't depend on the CounterModel") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:scoped_model/scoped_model.dart'; | |
| class CounterModel extends Model{ | |
| int _counter = 0; | |
| int get counter => _counter; | |
| void increment() { | |
| _counter++; |