欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flutter开发常见问题

程序员文章站 2022-03-11 09:49:53
...
  1. Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.
    sdk: flutter
    ^^^^^^^^^^^^^
    方法:dio要引入要对齐
    flutter开发常见问题

  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);
    }
  }