generateLocalIds method
Map<String, dynamic>
generateLocalIds(
- Arc arc
)
Implementation
Map<String, dynamic> generateLocalIds(Arc arc) {
var localRId = 1;
final localNotes = arc.getNotesForSlide(this).toList();
final localImages = arc.getImagesForSlide(this).toList();
for (var item in localNotes) {
item.localRId = ++localRId;
}
for (var item in localImages) {
item.localRId = ++localRId;
}
if (localNotes.isNotEmpty) {
notesId = arc.notes.first.localRId!;
}
final data = {
'notes': localNotes.map((e) => e.toJson()).toList(),
'images': localImages.map((e) => e.toJson()).toList(),
'comments': [],
'layoutId': layoutId,
'notesId': notesId,
};
for (final entry in imageRefs.entries) {
final image = entry.value;
final match = localImages.firstWhereOrNull((e) => e.path == image?.path);
data['imageId${entry.key}'] = match?.localRId ?? 1;
}
for (var i = 0; i < localNotes.length; i++) {
data['notesId${i + 1}'] = localNotes[i].localRId!;
}
return data;
}