Flutter 如何在屏幕底部放置一些按钮?

Flutter 如何在屏幕底部放置一些按钮?,flutter,flutter-layout,Flutter,Flutter Layout,我想把一些按钮放在屏幕的底部,但不使用条,因为我希望botton保持在其他小部件的上方,但保持在屏幕的按钮上,即使它们下面的小部件是可滚动的 您需要使用一个堆栈小部件,它接受子小部件。您将首先添加背景小部件,然后使用定位小部件来很好地。。。定位小部件,在本例中,这些小部件是您想要的按钮,位于您想要的屏幕底部的前景中 查看下面的示例代码: class BottomButtonPosition extends StatelessWidget { @override Widget build(

我想把一些按钮放在屏幕的底部,但不使用条,因为我希望botton保持在其他小部件的上方,但保持在屏幕的按钮上,即使它们下面的小部件是可滚动的


您需要使用一个堆栈小部件,它接受子小部件。您将首先添加背景小部件,然后使用定位小部件来很好地。。。定位小部件,在本例中,这些小部件是您想要的按钮,位于您想要的屏幕底部的前景中

查看下面的示例代码:

class BottomButtonPosition extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          ListView(children: <Widget>[
            ...List.generate(
              10,
              (index) => Container(
                    color: Colors.primaries.elementAt(index),
                    height: 100.0,
                  ),
            ),
          ]),
          Positioned(
            bottom: 0.0,
            right: 0.0,
            left: 0.0,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                IconButton(
                  icon: Icon(
                    Icons.play_arrow,
                    color: Colors.white,
                  ),
                  iconSize: 40,
                  onPressed: () {},
                ),
                IconButton(
                  icon: Icon(
                    Icons.skip_previous,
                    color: Colors.white,
                  ),
                  iconSize: 40,
                  onPressed: () {},
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
结果如下:


OP询问按钮,你的答案没有提到按钮,只是背景?谢谢你指出这一点。我在代码中包括了按钮,但我将进行编辑以在注释中指定按钮。使用堆栈布局