addNewLockTemplate method
Add a new lock template entry to the wallet state's cartesian indexing. Lock templates are at the y (template) layer. This new entry will be associated to the label given by template. The index of the new entry (and thus associated with the template label) will be automatically derived by the next available y-index.
template
A String label of the template to associate the new lockTemplate entry with
lockTemplate
The list of Lock Templates of the lock templates to add to the new Entries entry
Implementation
@override
Future<void> addNewLockTemplate(
String template, LockTemplate lockTemplate) async {
final latest = await templatesStore.findFirst(_instance,
finder: Finder(sortOrders: [SortOrder("y", false)]));
final y = latest != null ? ((latest["y"]! as int) + 1) : 0;
await templatesStore.add(
_instance,
Template(
y: y,
name: template,
lock: jsonEncode(lockTemplate.toJson()),
).toSembast,
);
}