batch insert points to db file when stroke finished

This commit is contained in:
2022-11-03 12:13:36 +01:00
parent 348886b5bb
commit 9be2c69ff5
4 changed files with 34 additions and 19 deletions

View File

@ -40,8 +40,23 @@ extension LineLoading on NoteFile {
});
}
Future<void> addPoints(int strokeid, List<Point> pts) async {
final batch = db().batch();
for (final p in pts) {
batch.insert('points', {
'x': p.point.dx,
'y': p.point.dy,
'thickness': p.thickness,
'strokeid': strokeid
});
}
await batch.commit();
}
Future<void> removeStroke(int id) async {
await db().delete('strokes', where: 'id = $id');
await db().delete('points', where: 'strokeid = $id');
final batch = db().batch();
batch.delete('strokes', where: 'id = $id');
batch.delete('points', where: 'strokeid = $id');
await batch.commit();
}
}