Flutter框架 在线

2791Flutter 问题集

Future< String>

The argument type 'Future< String>' can't be assigned to the parameter type 'String'.

类型错误 二种解决办法

第一种使用async和await

Future<Void> printDailyNewsDigest() async {

  String news = await gatherNewsReports();

  print(news);

}

第二种指定回调在回调中进行处理

void printDailyNewsDigest() {

  final future = gatherNewsReports();

  future.then((news) => print(news));

}

2613Flutter开发环境

Unable to 'pub upgrade' flutter tool. Retrying in five seconds

升级flutter时卡住了

解决方法

删除 flutter SDK中 bin/cache 文件夹

后再flutter upgrade就可以了