Flutter 問題總結

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

創(chuàng)建項目的根目錄上加上項目名,防止混亂

2.創(chuàng)建flutter項目名只能是小寫字母、數(shù)字、下劃線(不能大寫)

3.導入material出錯是還沒有獲取到package,終端執(zhí)行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

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容