Replies: 3 comments 1 reply
-
Methods you put in the class describing the table don't show up in the class describing a row of that table. You can use custom row classes to customize them entirely. An easier workaround might be to do this: extension RowToMap<D extends Insertable<D>> on D {
Map<String, Object?> toMap() {
return {
for (final entry in toColumns(false).entries)
entry.key: (entry.value as Variable).value,
};
}
} That should allow you to call |
Beta Was this translation helpful? Give feedback.
-
using Row class consist of adding annotation in entity class but I already have one and this is not possible to have 2 distinct annotations If I change @DataClassName to @UseRowClass all my code base is invalidated immediatly. |
Beta Was this translation helpful? Give feedback.
-
OK it seems that custom Row Classes is powerful (I more understand now). My extension seems to be operate good 👍 Why do not included this base and popular function toMap() directly into your generated drift code ? Thank you for your help again. |
Beta Was this translation helpful? Give feedback.
-
Hello Drift,
Context :
I would like to display my data (persisted into SQLite) into a Datatable Widget Flutter.
This Datatable Widget work around a DataRow Object that can be construct from a Map<String, Dynamic> object.
But the return object of my query Drift is a List
Idea:
I would like to add a method into my entity (like toMap) to help me to convert object easily into a loop
Issue:
If a add method into entity, this method is not recognize and I don't see it into generated drift_database.g.dart file.
Questions :
My code examples :
Query into repository :
treatment of return query :
My entity :
What do you think about those ?
Thank you for your package work and help.....
Beta Was this translation helpful? Give feedback.
All reactions