validate form before saving
This commit is contained in:
@@ -191,32 +191,34 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
}
|
||||
|
||||
void onSavePressed() {
|
||||
Navigator.of(context).pop(
|
||||
CreateTaskRequest(
|
||||
title: titleController.text,
|
||||
description: descriptionController.text,
|
||||
start: null,
|
||||
due: DateTime.tryParse(
|
||||
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
||||
if (formKey.currentState!.validate()) {
|
||||
Navigator.of(context).pop(
|
||||
CreateTaskRequest(
|
||||
title: titleController.text,
|
||||
description: descriptionController.text,
|
||||
start: null,
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user