diff --git a/lib/core/note.dart b/lib/core/note.dart index 2224de1e..1867605b 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -508,23 +508,6 @@ class Note with NotesNotifier { } } - Future addImageSync(String filePath) async { - var file = File(filePath); - var absImagePath = _buildImagePath(file); - file.copySync(absImagePath); - - var relativeImagePath = p.relative(absImagePath, from: parent.folderPath); - if (!relativeImagePath.startsWith('.')) { - relativeImagePath = './$relativeImagePath'; - } - var imageMarkdown = "![Image]($relativeImagePath)\n"; - if (body.isEmpty) { - body = imageMarkdown; - } else { - body = "$body\n$imageMarkdown"; - } - } - String _buildImagePath(File file) { String baseFolder; diff --git a/lib/screens/note_editor.dart b/lib/screens/note_editor.dart index 48b57d3d..ab212701 100644 --- a/lib/screens/note_editor.dart +++ b/lib/screens/note_editor.dart @@ -124,11 +124,13 @@ class NoteEditorState extends State with WidgetsBindingObserver { if (existingImages.isNotEmpty) { for (var imagePath in existingImages) { - try { - note!.addImageSync(imagePath); - } catch (e, st) { - Log.e("New Note Existing Image", ex: e, stacktrace: st); - } + () async { + try { + await note!.addImage(imagePath); + } catch (e, st) { + Log.e("New Note Existing Image", ex: e, stacktrace: st); + } + }(); } } }