_This issue was originally filed by bl...@google.com_
Would it be possible to make the following work?
testDriver..await deleteAll()
..await createNew()
..await refresh();
_Removed Type-Defect label._
_Added Type-Enhancement, Area-Language, Triaged labels._
I don't see this syntax happening. I'd put my money on #25986 instead, introducing a suffix form of await, so you could write, e.g.,
testDriver..deleteAll().await
..createNew().await
..refresh().await;
(or whatever syntax would be used for that).
The problem with allowing prefix operators to be used infix is that it's not clear how they bind.
If you write testDriver..await foo().bar()
, are you awaiting foo()
or foo().bar()
.
How about a..await b[42]
or a..await b.foo()[42]
.
So, probably won't happen as this.
+1, just made a mistake today:
final auth = await context.read<AuthStore>()..login();
this wouldn't work because I need to await login
, not a read
method
the only way is
final auth = context.read<AuthStore>();
await auth.login()
The desirable syntax is final auth = context.read<AuthStore>()..await login();
... Things like login().await
are counter-intuitive IMO.