It's been several hours and I couldn't find a solution. I have multiple queries working fine with flutter drift, but when I add a where statement I get the following error:
Unhandled Exception: type '(dynamic) => dynamic' is not a subtype of type '(HasResultSet) => Expression' of 'filter'
The query is:
Future<dynamic> getById(int id) async {
return await (db.select(table)..where((tbl) => tbl.id.equals(id))).getSingle();
}
If I remove ..where and add ..limit(1) the query runs fine:
Future<dynamic> getById(int id) async {
return await (db.select(table)..limit(1)).getSingle();
}
Any clue?
The problem seems that flutter can't infer the types, so I made the query with the requested ones:
Future<dynamic> getById(int id) async {
return await (db.select(table)..where((HasResultSet tbl) => table.id.equals(id) as Expression<bool>)).getSingle();
}
And now it's working fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With