【问题标题】:Error thrown on navigator pop until : "!_debugLocked is not true导航器弹出错误,直到:“!_debugLocked 不正确
【发布时间】:2022-01-07 12:03:17
【问题描述】:

每当我运行应用程序时,主屏幕最多只显示 5 秒,并且没有点击,我导航到另一个页面。 其中第二页是商品详情页,第一页商品按分类显示。

                itemBuilder: (context, index) => ItemCard(
                  product: products[index],
                  press: () => Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (context) => DetailsScreen(
                          product: products[index],
                        ),
                      )),
                )),
          ),
        ),
      ],
    );
  }
}```

错误:

The following assertion was thrown while handling a gesture:
Assertion failed: file:///C:/src/flutter/flutter/packages/flutter/lib/src/widgets/navigator.dart:4842:12
!_debugLocked
is not true

【问题讨论】:

    标签: android flutter dart navigator


    【解决方案1】:

    您必须确保在导航之前已构建小部件树,您可以通过像这样扭曲您的函数来做到这一点

    WidgetsBinding.instance.addPostFrameCallback((_) {
    
    Navigator.push(context, MaterialPageRoute(builder: (_) => 
         MyPage()));
    

    });

    【讨论】:

      猜你喜欢
      • 2019-09-01
      • 2020-10-30
      • 2021-08-26
      • 2022-01-07
      • 2015-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多