fixed bug that caused duedate to not setting after selecting

This commit is contained in:
2026-06-17 11:31:28 +02:00
parent f7c0d1050f
commit 12329d20e8
+8 -1
View File
@@ -17,6 +17,7 @@ class TaskEditPage extends StatefulWidget {
class _TaskEditPageState extends State<TaskEditPage> {
Task? task;
bool isInitialized = true;
final titleController = TextEditingController();
final descriptionController = TextEditingController();
final categoryController = TextEditingController();
@@ -29,7 +30,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
void didChangeDependencies() {
super.didChangeDependencies();
task = ModalRoute.of(context)!.settings.arguments as Task?;
if (task != null) {
if (task != null && !isInitialized) {
titleController.text = task!.title;
descriptionController.text = task!.description;
categoryController.text = task!.category;
@@ -40,6 +41,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
dueTimeController.text = task!.due != null
? TimeOfDay.fromDateTime(task!.due!).format(context)
: '';
isInitialized = true;
}
pageTitle = task?.title ?? 'CreateTask';
}
@@ -62,6 +64,10 @@ class _TaskEditPageState extends State<TaskEditPage> {
),
body: Form(
autovalidateMode: AutovalidateMode.onUnfocus,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05,
),
child: Column(
children: [
TextFormField(
@@ -139,6 +145,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: onSavePressed,
child: Icon(Icons.save),