Skip to content

Commit fe3ab77

Browse files
author
Vladimir Minkin
committed
Update of TodoVO to match new parsing rule required for mobile database
1 parent ea78ed7 commit fe3ab77

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class TodoVO {
22
TodoVO(this.id, this.text, this.note, this.completed);
3-
TodoVO.fromJson(Map<String, dynamic> json)
4-
: id = json['id'] as String,
5-
text = json['text'] as String,
6-
note = json['note'] as String,
7-
completed = json['completed'] as bool;
3+
TodoVO.fromJson(Map<dynamic, dynamic> json)
4+
: id = json['id'] as String,
5+
text = json['text'] as String,
6+
note = json['note'] as String,
7+
completed = json['completed'] as bool;
88

99
bool completed;
1010
String text;
@@ -13,10 +13,5 @@ class TodoVO {
1313

1414
bool visible = true;
1515

16-
Map<String, dynamic> toJson() => {
17-
'id': id,
18-
'text': text,
19-
'note': note,
20-
'completed': completed
21-
};
16+
Map<dynamic, dynamic> toJson() => {'id': id, 'text': text, 'note': note, 'completed': completed};
2217
}

example/_shared/lib/todo/model/todo_model.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TodoModel {
1616
for (final obj in await _dbService.retrieve(STORAGE_KEY) as List) {
1717
print('> TodoModel -> init: todo = $obj');
1818
if (obj != null) {
19-
final todoVO = TodoVO.fromJson(obj as Map<String, dynamic>);
19+
final todoVO = TodoVO.fromJson(obj as Map<dynamic, dynamic>);
2020
Wire.data(todoVO.id, value: todoVO);
2121
idsList.add(todoVO.id);
2222
if (!todoVO.completed) notCompletedCount++;
@@ -199,7 +199,7 @@ class TodoModel {
199199
}
200200

201201
void _saveChanges() {
202-
final List<Map<String, dynamic>> listOfTodoVO = [];
202+
final List<Map<dynamic, dynamic>> listOfTodoVO = [];
203203
for (final id in Wire.data(DataKeys.LIST_OF_IDS).value as List<String>) {
204204
listOfTodoVO.add((Wire.data(id).value as TodoVO).toJson());
205205
}

0 commit comments

Comments
 (0)