I am building a mobile application using flutter and moor as database library. I have to fetch all transactions for a particular month. My query is like below.
Future<List<Transaction>> fetchTransactionsByCategory(
String name, DateTime reportDate) {
return (select(transactions)
..where((i) {
final date = i.date;
return date.year.equals(reportDate.year) &
date.month.equals(reportDate.month) &
i.subCategory.equals(name);
}))
.get();
}
The issue is if the transaction time is May 01, 2021 12:00:00 AM, it is not coming under May report, instead it is coming under April report. I am able to understand in the database it is getting persisted as 30 Apr 2021 16:00:00 PM (timezone +8 here).
How I have to write the query to fetch the transactions based on local time zone? Any suggestions?
In your pubspec
intl: ^0.16.1
and importin your highest state(First state).
and then you can use it like ;