如何使列表在flutter中的singlechildscroll视图中可滚动?

问题描述 投票:0回答:1

我有一个带有嵌套底部导航栏和 singlechildscroll 视图的包装类,并且其中一个嵌套类内的列表没有滚动。

body: SingleChildScrollView(
          physics: const AlwaysScrollableScrollPhysics(),
          child: SizedBox(
            height: 883,
            child: Column(
              children: [
                Container(
                  margin: const EdgeInsets.all(25),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      
                SizedBox(
                  height: 660,
                  child: IndexedStack(
                    index: _selectedIndex,
                    children: [
                      HomeScreen(
                        globalKey: bottomNavigatorKey,
                      ),
                      const ProjectNavigator(),
                      const BookNavigator(),
                      const CartNavigator()
                    ],
                  ),
                )
              ],
            ),
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
          
          unselectedItemColor: AppColor.blue,
          key: bottomNavigatorKey,

          currentIndex: _selectedIndex,
          onTap: _onItemTapped,
          type: BottomNavigationBarType.fixed,
          selectedItemColor: AppColor.red,
          selectedIconTheme: const IconThemeData(color: AppColor.red),

          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Icon(
                Icons.home,
              ),
              label: 'Home',
            ),
            BottomNavigationBarItem(
              icon: Icon(
                Icons.description,
              ),
              label: 'Project',
            ),
            BottomNavigationBarItem(
              icon: Icon(
                Icons.book,
              ),
              label: 'Books',
            ),
            BottomNavigationBarItem(
              icon: Icon(
                Icons.shopping_cart,
              ),
              label: 'Cart',
            ),
          ],
        ),
      ),

我尝试了 mainwrapper 类的 customScroolview,但这也不起作用。任何想法如何解决这个问题。

flutter
1个回答
0
投票
Flexible(
        child: IndexedStack(
          index: _selectedIndex,
          children: [
            HomeScreen(
              globalKey: bottomNavigatorKey,
            ),
            const ProjectNavigator(),
            const BookNavigator(),
            const CartNavigator()
          ],
        ),
      )

尝试用这个代替这个

SizedBox(
                  height: 660,
                  child: IndexedStack(
                    index: _selectedIndex,
                    children: [
                      HomeScreen(
                        globalKey: bottomNavigatorKey,
                      ),
                      const ProjectNavigator(),
                      const BookNavigator(),
                      const CartNavigator()
                    ],
                  ),
                )

也许固定高度限制了滚动。希望对你有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.