Flutter : This expression has a type of 'void' so its value can't be used
Change your methods to 'Future':
Future<void> fetchSearch(String input) async {
and
Future<void> fetchLocation() async {
![Akhele](https://i.stack.imgur.com/Bl6Qp.jpg?s=256&g=1)
Akhele
Since my childhood, I have been fond of electronics. I discovered programming in 2010, so I moved my passion from electronics to it. Trying to learn it myself. I spent years struggling between the free courses I studied, creating projects, and forgetting them to move on to new projects. it was/still a hobby for me. Then after I got a Bachelor of Physical Sciences I decided to specialize in programming, and after two years I’ve got my diploma in informatics development. And now I study and work as a freelancer + my day job. you can read more about me: https://www.akhele.com
Updated on December 30, 2022Comments
-
Akhele over 1 year
I have a problem with the two lines after adding async and await a new two errors appear in the await lines
"This expression has a type of 'void' so its value can't be used."
this is the code with the problem
void onTextFieldSubmitted(String input) async { await fetchSearch(input); await fetchLocation(); }
you can see the source code here https://github.com/Akhele/Flutter-Weather-App/blob/master/lib/main.dart
-
Hadi Norouzi about 3 yearschange return type of your function to
Future<void>
.
-