簡體   English   中英

Flutter 顯示舊錯誤

[英]Flutter showing old errors

我正在編寫一個 flutter 應用程序,但是當我想在 Android Emulator (Ctrl+F5) 上測試它時,我遇到了一個無法修復的錯誤。 這是其中的一部分:

I/flutter (13782): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (13782): The following assertion was thrown during performResize():
I/flutter (13782): Vertical viewport was given unbounded height.
I/flutter (13782): Viewports expand in the scrolling direction to fill their container. In this case, a vertical
I/flutter (13782): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (13782): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (13782): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (13782): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (13782): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (13782): the height of the viewport to the sum of the heights of its children.
I/flutter (13782):
I/flutter (13782): The relevant error-causing widget was:
I/flutter (13782):   ListView  (file:///D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dart:19:18)

正如您在最后一行中看到的,它說錯誤的原因是D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dartListView 問題是我在那個文件中沒有ListView (目前,但我以前有它)而且那個路徑甚至不存在了!

如果有幫助,這是all_obj_screen.dart文件:

class AllObjScreen extends StatefulWidget {
  @override
  _AllObjScreenState createState() => _AllObjScreenState();
}

class _AllObjScreenState extends State<AllObjScreen> {
  @override
  Widget build(BuildContext context) {
    final objects = Provider.of<Objs>(context);

    return Center(
      child: Text(
        '${objects.items.length}',
        style: TextStyle(
          color: Colors.white,
          fontSize: 25,
        ),
      ),
    );
  }
}

所以我認為問題不在於我的代碼,而在於 Visual Studio Code。 如何解決這個問題?

編輯:我嘗試在 Visual Studio Code 和 Android Studio 上運行該應用程序,但問題是相同的。 我也試過重新安裝 IDE 和 flutter,但根本沒有運氣。

自 1.12 版以來,我遇到了同樣的問題。 重啟設備會清除日志,但我希望 Flutter 能在未來的版本中糾正這個問題。 這只是使用 android 設備發生的。 在 iOS 中工作正常。

嘗試:

flutter logs -c

(要清除日志,請在項目目錄中運行)

清潔過程后,然后按 CTRL + C 並為以下問題回答 Y。 希望它會有所幫助。 謝謝

簡短的回答:刪除該設備(模擬器)並創建另一個新設備。

在此處輸入圖片說明

長長的故事:

我有同樣的問題! 代碼是完美的,突然間沒有任何變化,我得到了一大堆基於不應該被觸發的事件的錯誤!

我嘗試了flutter clean但它沒有解決問題並嘗試了所有方法,即使我刪除了處理錯誤觸發事件的所有代碼,但我對那些不斷出現的錯誤沒有運氣,而沒有代碼來生成它們!!

直到我想嘗試另一個模擬器,然后奇跡發生了! 沒有錯誤!

你可以看到它: https : //github.com/flutter/flutter/issues/46815 此問題已在 flutter 1.12.13+hotfix8 版本中修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM