flutter开发常见问题

  1. Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.
    sdk: flutter
    ^^^^^^^^^^^^^
    方法:dio要引入要对齐
    在这里插入图片描述

  2. -Waiting for another flutter command to release the startup lock。
    方法:
    1、打开flutter的安装目录/bin/cache/
    2、删除lockfile文件
    3、重启AndroidStudio

  3. 由于在国内访问Flutter有时可能会受到限制,Flutter官方为中国开发者搭建了临时镜像,大家可以将如下环境变量加入到用户环境变量中:

    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

  4. type ‘Future<Response>’ is not a subtype of type 'Response

void getHttp() async {
    try {
      Response response =  DioManager.singleton.dio.get("http://www.baidu.com");

      print(response);
    } catch (e) {
      print(e);
    }
  }

网络请求返回错误
原因:少了 await
应该是

void getHttp() async {
    try {
      Response response = await DioManager.singleton.dio.get("http://www.baidu.com");

      print(response);
    } catch (e) {
      print(e);
    }
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值