File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ var sections = [
3
+ {
4
+ 'title' : 'Getting Started' ,
5
+ 'resetLessonPosition' : false ,
6
+ 'lessons' : [
7
+ {'name' : 'Welcome' },
8
+ {'name' : 'Installation' }
9
+ ]
10
+ },
11
+ {
12
+ 'title' : 'Basic Operator' ,
13
+ 'resetLessonPosition' : false ,
14
+ 'lessons' : [
15
+ {'name' : 'Addition / Substraction' },
16
+ {'name' : 'Multiplication / Division' }
17
+ ]
18
+ },
19
+ {
20
+ 'title' : 'Advanced Topics' ,
21
+ 'resetLessonPosition' : true ,
22
+ 'lessons' : [
23
+ {'name' : 'Mutability' },
24
+ {'name' : 'Immutability' }
25
+ ]
26
+ }
27
+ ];
28
+
29
+ void main () {
30
+ var sectionCounter = 0 ;
31
+ var lessonCounter = 0 ;
32
+
33
+ for (var section in sections) {
34
+ if (section['resetLessonPosition' ] as bool ) {
35
+ lessonCounter = 0 ;
36
+ }
37
+ section['position' ] = ++ sectionCounter;
38
+
39
+ for (var lesson in section['lessons' ] as List ) {
40
+ lesson['position' ] = (++ lessonCounter).toString ();
41
+ }
42
+ }
43
+ print (sections);
44
+ }
You can’t perform that action at this time.
0 commit comments