I'm using moor_flutter to persist my data in an SQLite database in my Flutter application. One of my columns for the sake of argument looks like this:
class Clients extends Table {
// Autoincrement automatically sets this to be a primary key
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 60)();
TextColumn get phone => text().withLength(min: 1, max: 50)();
}
I'm looking to store an array of clients I have recently opened in a List of length 10. Every time somebody would interact with that client, the list would place that client on the top of the list and remove the last one so that it would always be 10. It could also reorder them to bubble one from the middle, up to the top.
In any case, what I'm looking to do is create a new table called "Recents" which would have a single field of type List like so:
class Recents extends Table {
List<Client> recents => List<Client>[10].withLength(min: 0, max:10)()();
}
I couldn't find anything usable on the interwebz so here we are StackOverflowers! How would you solve this conundrum?
Users Table
Phone Numbers Table