Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit d39e62a

Browse files
vicbjbdeboer
authored andcommitted
fix(form example): watched collections can not be mutated
1 parent e5584e1 commit d39e62a

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

example/web/forms/form.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,33 @@ class FormCtrl {
1212
static const String COLOR_RGB = "rgb";
1313
static const String COLOR_NAME = "name";
1414

15+
static const _COLOR_TYPES = const [COLOR_RGB, COLOR_HSL, COLOR_HEX, COLOR_NAME];
16+
17+
static const _RESOLUTIONS = const ['1024x600',
18+
'1280x800',
19+
'1366x768',
20+
'1440x900',
21+
'1600x900',
22+
'1680x1050',
23+
'1920x1080',
24+
'1920x1200',
25+
'2560x1440',
26+
'2560x1600'];
27+
1528
Scope scope;
1629
NgForm form;
17-
List colors = [];
18-
List lastFormattedColors = [];
30+
final List colors = [];
31+
final List formattedColors = [];
1932

2033
FormCtrl(Scope this.scope, NgForm this.form) {
2134
newColor(COLOR_HEX, '#222');
2235
newColor(COLOR_HEX, '#444');
2336
newColor(COLOR_HEX, '#000');
2437
}
2538

26-
get color_types => [COLOR_RGB, COLOR_HSL, COLOR_HEX, COLOR_NAME];
27-
get resolutions => [
28-
'1024x600',
29-
'1280x800',
30-
'1366x768',
31-
'1440x900',
32-
'1600x900',
33-
'1680x1050',
34-
'1920x1080',
35-
'1920x1200',
36-
'2560x1440',
37-
'2560x1600'
38-
];
39+
List<String> get color_types => _COLOR_TYPES;
40+
41+
List<String> get resolutions => _RESOLUTIONS;
3942

4043
submit() {
4144
this.form.reset();
@@ -56,7 +59,7 @@ class FormCtrl {
5659
}
5760

5861
formatColors() {
59-
var formatted = [];
62+
formattedColors.clear();
6063
colors.forEach((color) {
6164
var value = null;
6265
switch(color['type']) {
@@ -84,11 +87,10 @@ class FormCtrl {
8487
break;
8588
}
8689
if(value != null) {
87-
formatted.add(value);
90+
formattedColors.add(value);
8891
}
8992
});
90-
lastFormattedColors = formatted;
91-
return formatted;
93+
return formattedColors;
9294
}
9395

9496
newColor([String type = COLOR_HEX, String color]) {

0 commit comments

Comments
 (0)