Remove Note.addImageSync

We can just always use the async version.
This commit is contained in:
Vishesh Handa
2021-08-04 08:28:10 +02:00
parent a0a97aa8cb
commit ef1536223d
2 changed files with 7 additions and 22 deletions

View File

@ -508,23 +508,6 @@ class Note with NotesNotifier {
}
}
Future<void> 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;

View File

@ -124,11 +124,13 @@ class NoteEditorState extends State<NoteEditor> 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);
}
}();
}
}
}