diff --git a/coverage_badge.svg b/coverage_badge.svg
index db8bc59..9d3823a 100644
--- a/coverage_badge.svg
+++ b/coverage_badge.svg
@@ -6,13 +6,13 @@
-
-
+
+
coverage
coverage
- 91%
- 91%
+ 79%
+ 79%
diff --git a/lib/main.dart b/lib/main.dart
index 757d2f9..305addf 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,6 +1,5 @@
import 'package:crud_todo_app/common/adaptive_contextual_layout.dart';
-import 'package:crud_todo_app/navigator/crud_todo_information_parser.dart';
-import 'package:crud_todo_app/navigator/crud_todo_router_delegate.dart';
+import 'package:crud_todo_app/provider_dependency.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
@@ -19,19 +18,14 @@ Future main() async {
runApp(const ProviderScope(child: TodoListApp()));
}
-class TodoListApp extends StatefulWidget {
+class TodoListApp extends ConsumerWidget {
const TodoListApp({Key? key}) : super(key: key);
@override
- _TodoListAppState createState() => _TodoListAppState();
-}
-
-class _TodoListAppState extends State {
- final _todoRouterDelegate = CrudTodoRouterDelegate();
- final _todoInfoParser = CrudTodoInformationParser();
+ Widget build(BuildContext context, WidgetRef ref) {
+ final _todoRouterDelegate = ref.watch(crudTodoRouterDelegateProvider);
+ final _todoInfoParser = ref.watch(crudTodoInformationParserProvider);
- @override
- Widget build(BuildContext context) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
theme: ThemeData(
diff --git a/lib/navigator/config/crud_todo_config.dart b/lib/navigator/config/crud_todo_config.dart
index 406279c..bc926cb 100644
--- a/lib/navigator/config/crud_todo_config.dart
+++ b/lib/navigator/config/crud_todo_config.dart
@@ -1,83 +1,19 @@
-import 'package:equatable/equatable.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
-class CrudTodoConfig extends Equatable {
- const CrudTodoConfig.categoryList()
- : currentCategoryId = null,
- currentTodoId = null,
- isTodoNew = false,
- isTodoUpdate = false,
- isUnknown = false;
+part 'crud_todo_config.freezed.dart';
- const CrudTodoConfig.todoList({String? categoryId})
- : currentCategoryId = categoryId,
- currentTodoId = null,
- isTodoNew = false,
- isTodoUpdate = false,
- isUnknown = false;
+@freezed
+class CrudTodoConfig with _$CrudTodoConfig {
+ const factory CrudTodoConfig.categoryList() = CrudTodoConfigCategoryList;
- const CrudTodoConfig.addTodo({String? categoryId})
- : currentCategoryId = categoryId,
- currentTodoId = null,
- isTodoNew = true,
- isTodoUpdate = false,
- isUnknown = false;
+ const factory CrudTodoConfig.todoList(String categoryId) =
+ CrudTodoConfigTodoList;
- const CrudTodoConfig.updateTodo({String? categoryId, String? todoId})
- : currentCategoryId = categoryId,
- currentTodoId = todoId,
- isTodoNew = false,
- isTodoUpdate = true,
- isUnknown = false;
+ const factory CrudTodoConfig.addTodo(String categoryId) =
+ CrudTodoConfigAddTodo;
- const CrudTodoConfig.unknown()
- : currentCategoryId = null,
- currentTodoId = null,
- isTodoNew = false,
- isTodoUpdate = false,
- isUnknown = true;
+ const factory CrudTodoConfig.updateTodo(String categoryId, String todoId) =
+ CrudTodoConfigUpdateTodo;
- final String? currentCategoryId;
- final String? currentTodoId;
- final bool isTodoNew;
- final bool isTodoUpdate;
- final bool isUnknown;
-
- bool get isPageUnknown => isUnknown;
-
- bool get isCategoryListPage =>
- currentCategoryId == null &&
- currentTodoId == null &&
- !isTodoNew &&
- !isTodoUpdate &&
- !isUnknown;
-
- bool get isTodoListPage =>
- currentCategoryId != null &&
- currentTodoId == null &&
- !isTodoNew &&
- !isTodoUpdate &&
- !isUnknown;
-
- bool get isAddTodoPage =>
- currentCategoryId != null &&
- currentTodoId == null &&
- isTodoNew &&
- !isTodoUpdate &&
- !isUnknown;
-
- bool get isUpdateTodoPage =>
- currentCategoryId != null &&
- currentTodoId != null &&
- !isTodoNew &&
- isTodoUpdate &&
- !isUnknown;
-
- @override
- List