如何将固定在底部的容器添加到棉条颤振器上

Tai*_*aio 2 flutter flutter-layout

我有一个 sliverAppbar 和一个滚动的 sliver 列表。然而,我需要在屏幕底部有一个固定的容器,无论滚动位置或屏幕上的其他任何内容如何,​​它都不会移动,相当于position fixedWeb CSS 中的容器。我已经使用了 aSliverToBoxAdapterstackwidgetpositioned来实现这个,但它抛出了一个错误

    Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[100],
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            primary: true,
            pinned: true,
            snap: false,
            elevation: 1.0,
            backgroundColor: Colors.blueAccent,
            floating: false,
            expandedHeight: 200.0,
            title: Text(
              "Title",
              style: TextStyle(
                  // color: Colors.grey[900]
                  ),
            ),
            flexibleSpace: FlexibleSpaceBar(
              background: Image.network(
                "https://images.pexels.com/photos/20990/pexels-photo-20990.jpeg?auto=compress&cs=tinysrgh=650&w=940",
                height: double.infinity,
                width: double.infinity,
                fit: BoxFit.cover,
              ),
            ),
          ),
          SliverList(
              delegate: SliverChildListDelegate([
            Container(color: Colors.red, height: 150.0),
            Container(color: Colors.purple, height: 150.0),
            Container(color: Colors.green, height: 150.0),
            Container(color: Colors.red, height: 150.0),
            Container(color: Colors.purple, height: 150.0),
            Container(color: Colors.green, height: 150.0),
          ])),
          SliverToBoxAdapter(
              child: Stack(
            children: [
              Positioned(
                bottom: 0,
                child: Container(
                  height: 80.0,
                  color: Colors.yellowAccent,
                ),
              ),
            ],
          )),
        ],
      ),
    );
  }
Run Code Online (Sandbox Code Playgroud)

小智 5

您可以尝试向脚手架添加底部导航栏

   Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[100],
      body: CustomScrollView(
        slivers: []
      ),
      bottomNavigationBar: Container(),
      
    );
  }
```
Run Code Online (Sandbox Code Playgroud)