-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watching a future returning function leads to type case error #29
Comments
Thanks for reporting, I will look into it |
Hi, I added a new branch and PR with a fix #30 Could you please verify that it's works (you can directly reference the branch from your pubspec) |
Hi, thanks for the quick fix. I tested it out and it works. One thing I noticed is that this only happened when Future<ItemTemplateViewModel?> getItemTemplateWithId(int id) async {
final row = await _joinValues(select(itemTemplates)..where((li) => li.id.equals(id))).getSingleOrNull();
return _rowToViewModel(row);
} |
It might be, that it only really happend when the returned value was null. But in general I wouldn't implement it this way as it really will create a new Future on every call that is awaited and then leads to a rebuild which creates a new future. |
Fixed in V1.4.2 now on pub |
Hi there,
as the title describes an error is thrown if you try to watch a future based on a function that is returning a future.
Error:
Line throwing the error:
watchFuture call:
getItemTemplateById signature:
I suspect this might be a bug in registerFutureHandler. The following is the code block including the line throwing the error and the code before it
initialValueProvider?.call as R?;
is trying to cast the function to R instead of calling it and then casting. Given that at all other times (in this file) the.call
is actually being called, this is most likely a bug. Changing it to: initialValueProvider?.call() as R?;
works without throwing an error.The text was updated successfully, but these errors were encountered: