mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 20:43:20 +08:00
ChecklistEditor: Remove trailing empty items
This commit is contained in:
@ -181,13 +181,17 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Note getNote() {
|
Note getNote() {
|
||||||
var note = checklist.note;
|
// Remove trailing empty items
|
||||||
if (checklist.items.length == 1) {
|
while (checklist.items.isNotEmpty) {
|
||||||
var item = checklist.items.first;
|
var last = checklist.items.last;
|
||||||
if (item.checked == false && item.text.trim().isEmpty) {
|
if (last.checked == false && last.text.trim().isEmpty) {
|
||||||
note.body = "";
|
checklist.removeAt(checklist.items.length - 1);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var note = checklist.note;
|
||||||
note.title = _titleTextController.text.trim();
|
note.title = _titleTextController.text.trim();
|
||||||
note.type = NoteType.Checklist;
|
note.type = NoteType.Checklist;
|
||||||
return note;
|
return note;
|
||||||
|
Reference in New Issue
Block a user