【问题标题】:Flutter : This expression has a type of 'void' so its value can't be usedFlutter:这个表达式的类型是 'void',所以它的值不能被使用
【发布时间】:2021-09-09 15:02:06
【问题描述】:

这两行有问题 添加异步和等待后 在等待行中出现了一个新的两个错误

“这个表达式的类型是'void',所以它的值不能被使用。”

这是有问题的代码

  void onTextFieldSubmitted(String input) async {
    
    await fetchSearch(input);
    await fetchLocation();
    
  }

您可以在此处查看源代码 https://github.com/Akhele/Flutter-Weather-App/blob/master/lib/main.dart

【问题讨论】:

  • 将函数的返回类型更改为Future<void>

标签: flutter android-studio dart mobile


【解决方案1】:

将您的方法更改为“未来”:

Future<void> fetchSearch(String input) async {

Future<void>  fetchLocation() async {

【讨论】:

    猜你喜欢
    • 2023-01-28
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2023-02-23
    • 1970-01-01
    • 1970-01-01
    • 2022-07-21
    相关资源
    最近更新 更多