Skip to content

Commit 1f273d7

Browse files
blueneogeogitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent e163323 commit 1f273d7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

guide/writing-reactive-code.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,32 @@ In any reactive app you want to be able to inform views to react to the data cha
7171

7272
## Creating a view
7373

74+
To present the app, we need two basic things:
75+
76+
* the view model, a class that represents what we want to show on the page and handles any events and has presentation code
77+
* the view, which contains code that lays out the widgets that paint what we see
78+
79+
We want our app to look like this:
80+
81+
82+
83+
Our view model starts out simple, for now it only needs a reference to the app, so it can show the tasks we have:
84+
85+
{% code-tabs %}
86+
{% code-tabs-item title="lib/pages/taskspage/taskspage-model.dart" %}
87+
```dart
88+
import 'package:meta/meta.dart';
89+
import 'package:scoped_model/scoped_model.dart';
90+
import 'package:todolist/model/app-model.dart';
91+
92+
class TasksPageModel extends Model {
93+
TasksPageModel({@required this.app});
94+
95+
final AppModel app;
96+
}
97+
```
98+
{% endcode-tabs-item %}
99+
{% endcode-tabs %}
100+
74101

75102

0 commit comments

Comments
 (0)