在 Flutter 中将 TabBar 与 SliverChildListDelegate 结合使用

Using TabBar with SliverChildListDelegate in Flutter

我需要在我用Flutter开发的应用程序的屏幕上添加一个TabBar,但是我想添加的地方是在SliverAppBar的底部。我该怎么做?

altKisim() 包含一个列。

Column(
children:[
Widget..
Divider(),
--This is where I want to add--
Widget..
],
);

有没有办法添加到这个代码片段,或者我必须完全改变构建?因为我找到的所有解决方案都提示我需要更改它。

对话样本


class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  get tabView => [
        ...List.generate(
          3,
          (index) => Container(
            height: 700,
            color: index.isEven ? Colors.deepPurple : Colors.deepOrange,
            child: Text("index $index"),
          ),
        ).toList(),
      ];

  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: LayoutBuilder(
        builder: (context, constraints) => CustomScrollView(
          slivers: [
            SliverAppBar(
              title: Text("AppBar"),
              expandedHeight: 300,
              floating: true,
              flexibleSpace: FlexibleSpaceBar(
                background: Container(
                  color: Colors.cyanAccent,
                  child: Column(
                    children: [Text("asdasd")],
                  ),
                ),
              ),
            ),
            SliverToBoxAdapter(
              child: tabView[_currentIndex],
            )
          ],
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(
        showSelectedLabels: false,
        showUnselectedLabels: false,
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: "Home",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.ac_unit),
            label: "AC",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.umbrella),
            label: "umbrella",
          ),
        ],
      ),
    );
  }
}

你的情况解决了吗?