From e6be9aa228d40f59db4570ab8f8aaf3e5931f24d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 6 Jun 2020 12:31:24 +0200 Subject: [PATCH] Ensure new notes always have a proper file ending --- lib/core/note.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/core/note.dart b/lib/core/note.dart index 53a4f479..71766b72 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -70,22 +70,24 @@ class Note with NotesNotifier { Note.newNote(this.parent) { created = DateTime.now(); _loadState = NoteLoadState.Loaded; + _fileFormat = NoteFileFormat.Markdown; } String get filePath { if (_filePath == null) { _filePath = p.join(parent.folderPath, _buildFileName()); switch (_fileFormat) { - case NoteFileFormat.Markdown: - if (!_filePath.toLowerCase().endsWith('.md')) { - _filePath += '.md'; - } - break; case NoteFileFormat.Txt: if (!_filePath.toLowerCase().endsWith('.txt')) { _filePath += '.txt'; } break; + case NoteFileFormat.Markdown: + default: + if (!_filePath.toLowerCase().endsWith('.md')) { + _filePath += '.md'; + } + break; } }