Flutter 问题总结

1."desktop" already exists at the specified project location

创建项目的根目录上加上项目名,防止混乱

2.创建flutter项目名只能是小写字母、数字、下划线(不能大写)

3.导入material出错是还没有获取到package,终端执行flutter packages get ,接下来终端报错:Error: No pubspec.yaml file found. 需要终端切换到项目目录下。

4.Waiting for another flutter command to release the startup lock.. 终端命令报错

在FlutterSDk目录上,bin/cache/lockfile,删除lockfile

5.自定义了一个Sharedpreferences操作的工具类,在读取时报错,type'Future<dynamic>' is not a subtype of type 'String' in type cast

Future<dynamic> getData(String key) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.get(key);
  }

分析:由于方法是异步的,不能直接使用。
解决:getData('key').then(value){};

6.报错Incorrect use of ParentDataWidget.
在Widge中使用了不正确的组件,如在row、column中使用了Positioned

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。