【问题标题】:Flutter CupertinoTabScaffold tabBuilder errorFlutter CupertinoTabScaffold tabBuilder错误
【发布时间】:2022-12-12 12:41:55
【问题描述】:

我想让 BottomNavBar 在我的应用程序中始终保持打开状态。 当我编译我的代码时,我得到这个错误: RenderBox 未布局:RenderIgnorePointer#59187 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE DETACHED

我正在尝试通过以下方式进行操作:

bottomNavigationBar: CupertinoTabScaffold(
            tabBar: CupertinoTabBar(
              iconSize: 30,
              currentIndex: currentIndex,
              onTap: (index) => setState(() => currentIndex = index),
              items: [
                BottomNavigationBarItem(icon: Icon(Icons.home, size: 25)),
                BottomNavigationBarItem(
                    icon: Icon(
                  Icons.store,
                  size: 25,
                )),
                BottomNavigationBarItem(
                    icon: Icon(Icons.shopping_bag, size: 25)),
                BottomNavigationBarItem(icon: Icon(Icons.person, size: 25)),
              ],
            ),
            tabBuilder: (BuildContext context, int index) {
              return CupertinoTabView(
                builder: (BuildContext context) {
                  return SafeArea(
                    top: false,
                    bottom: false,
                    child: MaterialApp(
                      home: CupertinoPageScaffold(
                        resizeToAvoidBottomInset: false,
                        child: MainScreen(
                          currentIndex: currentIndex,
                        ),
                      ),
                    ),
                  );
                },
              );
            }));

请告诉我如何让它工作,这样做有多正确?

【问题讨论】:

    标签: flutter dart bottomnavigationview


    【解决方案1】:

    从您提供的代码 sn-p 中不清楚您是如何尝试使底部导航栏保持打开状态。但是,您收到的错误消息表明您的应用布局存在问题。 RenderBox 类用于表示小部件的布局,错误消息表明 RenderIgnorePointer 小部件的 RenderBox 布局不正确。

    要修复此错误,您可能需要确保应用中的所有小部件都已正确布局。这可能涉及使用布局小部件(例如容器、行和列)来正确定位和调整小部件的大小。它还可能涉及使用填充、边距和其他布局属性来调整小部件的布局。

    至于关于保持底部导航栏打开的具体问题,您可以尝试将 CupertinoPageScaffold 的 resizeToAvoidBottomInset 属性设置为 false。这将防止底部导航栏被键盘或其他屏幕元素向上推。但是,尚不清楚这是否会解决您看到的错误,因为它可能是由您的应用程序布局的其他问题引起的。我建议查看您应用中的其他小部件并确保它们的布局正确以避免此错误。

    【讨论】:

      猜你喜欢
      • 2022-12-04
      • 1970-01-01
      • 2019-12-26
      • 2021-11-20
      • 2019-11-26
      • 2022-10-04
      • 2018-03-22
      • 2021-01-06
      • 2021-11-14
      相关资源
      最近更新 更多