validate form before saving
This commit is contained in:
@@ -191,32 +191,34 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onSavePressed() {
|
void onSavePressed() {
|
||||||
Navigator.of(context).pop(
|
if (formKey.currentState!.validate()) {
|
||||||
CreateTaskRequest(
|
Navigator.of(context).pop(
|
||||||
title: titleController.text,
|
CreateTaskRequest(
|
||||||
description: descriptionController.text,
|
title: titleController.text,
|
||||||
start: null,
|
description: descriptionController.text,
|
||||||
due: DateTime.tryParse(
|
start: null,
|
||||||
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
due: DateTime.tryParse(
|
||||||
|
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
||||||
|
),
|
||||||
|
isCompleted: false,
|
||||||
|
category: categoryController.text,
|
||||||
|
subtasks: [],
|
||||||
|
url: urlController.text,
|
||||||
|
alarms: alarmRequests.map<Alarm>((e) {
|
||||||
|
if (e is CreateFixedTimeAlarmRequest) {
|
||||||
|
return e.toAlarm(generateId());
|
||||||
|
}
|
||||||
|
if (e is CreateRelativeTimeAlarmRequest) {
|
||||||
|
return e.toAlarm(generateId());
|
||||||
|
}
|
||||||
|
if (e is LocationAlarm) {
|
||||||
|
return e.toAlarm(generateId());
|
||||||
|
}
|
||||||
|
throw TypeError();
|
||||||
|
}).toList(),
|
||||||
),
|
),
|
||||||
isCompleted: false,
|
);
|
||||||
category: categoryController.text,
|
}
|
||||||
subtasks: [],
|
|
||||||
url: urlController.text,
|
|
||||||
alarms: alarmRequests.map<Alarm>((e) {
|
|
||||||
if (e is CreateFixedTimeAlarmRequest) {
|
|
||||||
return e.toAlarm(generateId());
|
|
||||||
}
|
|
||||||
if (e is CreateRelativeTimeAlarmRequest) {
|
|
||||||
return e.toAlarm(generateId());
|
|
||||||
}
|
|
||||||
if (e is LocationAlarm) {
|
|
||||||
return e.toAlarm(generateId());
|
|
||||||
}
|
|
||||||
throw TypeError();
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPopInvoked(bool didPop, Object? result) {
|
void onPopInvoked(bool didPop, Object? result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user