Closed airxnoor closed 4 years ago
Hi @airthings-noordawod
Can you please provide your flutter doctor -v
and a minimal complete reproducible code sample?
Thank you
Sure thing.
Complete working example No.1:
This demonstrates the problem with having a _future
variable that may or may not return a value of type String
. The error reported by Dart Analyzer in this case: The argument type 'Future<String?>' can't be assigned to the parameter type 'Future<String>?'
.
--
Complete working example No.2:
This demonstrates the problem with having a FutureBuilder
of type String?
(since the latter isn't a subtype of Object
). The error reported by Dart Analyzer in this case: 'String?' doesn't extend 'Object'
.
I hope these demonstrate the problem of (chicken and egg) :)
This is reproducible with latest master
channel.
By the way, one more thing about the latest changes in async.dart:
Now it's not possible to use void
as T, like in: FutureBuilder<void>
.
Reported elsewhere for other parts of Flutter: https://github.com/flutter/flutter/issues/65938#issuecomment-693697508
In async.dart, there are few other places where the definition should be fixed (f.ex: StreamBuilderBase):
Current:
final Future<T>? future;
-OR-
final Stream<T>? stream;
To be changed to:
final Future<T?> future;
-AND-
final Stream<T?> stream;
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
Hi,
The recent changes to add nullability support has caused
FutureBuilder<T>
to be unusable. Consider this code snippet:It's not possible to use the above code anymore as Dart Analyzer screams about
error: The argument type 'Future<SomeModel?>' can't be assigned to the parameter type 'Future<SomeModel>?'
Now, if you change the
FutureBuilder
to readFutureBuilder<SomeModel?>
instead, then you get another error:error: 'SomeModel?' doesn't extend 'Object'.
My gut feeling: recent changes made to
FutureBuilder
introduced a typo:Current
FutureBuilder
property inasync.dart
:I think this should instead be defined as: