Skip to content

Commit 56beb68

Browse files
committed
Merge branch 'release/1.2.1.1' into main
2 parents e0c1787 + c461f66 commit 56beb68

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

lib/domain/storage_repository.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ abstract class StorageRepository {
1212
}
1313

1414
const String VIEW_COMPLETED_ITEMS_KEY = "view_completed_items";
15-
const String VIEW_COMPLETED_ITEMS_KEY_NONE = "NONE";

lib/presentation/todo_list/todo_list_model.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ class TodoListModel extends ChangeNotifier {
1515
@required StorageRepository storageRepository,
1616
@required TodoItemRepository todoItemRepository,
1717
}) : _storageRepository = storageRepository,
18-
_todoItemRepository = todoItemRepository {
19-
this.viewCompletedItems =
20-
(loadViewCompletedItems().toString() == "true") ? true : false;
21-
}
22-
18+
_todoItemRepository = todoItemRepository;
2319
final TodoItemRepository _todoItemRepository;
2420
final StorageRepository _storageRepository;
2521
List<TodoItem> list = [];
2622
bool viewCompletedItems;
2723

24+
Future<void> init() async {
25+
viewCompletedItems = await loadViewCompletedItems();
26+
await getTodoList();
27+
}
28+
2829
Future<void> getTodoList() async {
2930
list = await _todoItemRepository.findAll(
3031
viewCompletedItems: viewCompletedItems);
@@ -54,12 +55,13 @@ class TodoListModel extends ChangeNotifier {
5455
VIEW_COMPLETED_ITEMS_KEY, viewCompletedItems.toString());
5556
}
5657

57-
Future<String> loadViewCompletedItems() async {
58+
Future<bool> loadViewCompletedItems() async {
5859
if (!await _storageRepository.isExistKey(VIEW_COMPLETED_ITEMS_KEY)) {
59-
return VIEW_COMPLETED_ITEMS_KEY_NONE;
60+
return null;
6061
} else {
61-
return await _storageRepository
62+
final result = await _storageRepository
6263
.loadPersistenceStorage(VIEW_COMPLETED_ITEMS_KEY);
64+
return result == 'true';
6365
}
6466
}
6567
}

lib/presentation/todo_list/todo_list_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TodoListPage extends StatelessWidget {
2525
create: (_) => TodoListModel(
2626
storageRepository: context.read<StorageRepository>(),
2727
todoItemRepository: context.read<TodoItemRepository>(),
28-
)..getTodoList(),
28+
)..init(),
2929
child: Scaffold(
3030
appBar: AppBar(
3131
title: Text("TODOAppSample-Flutter"),

test/todo_list_model_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void main() {
149149
// 結果確認
150150
expect(
151151
await storageRepository.isExistKey(VIEW_COMPLETED_ITEMS_KEY), false);
152-
expect(result, VIEW_COMPLETED_ITEMS_KEY_NONE);
152+
expect(result, null);
153153
});
154154

155155
test('正常系:keyがある時', () async {

0 commit comments

Comments
 (0)