【问题标题】:Flutter : Add 2 buttons, one on top of image and other on bottom of image in flutterFlutter:在颤动中添加 2 个按钮,一个在图像顶部,另一个在图像底部
【发布时间】:2021-11-24 13:57:59
【问题描述】:

添加 2 个按钮,一个在图像顶部,另一个在图像底部。 请参考下图。

我想实现这个。

【问题讨论】:

  • 请添加您的代码以及预期结果。
  • 你能把到目前为止你尝试过的内容包括在内吗?

标签: flutter dart flutter-layout


【解决方案1】:

您可以使用带有图像和 ElevatedBUttons 的堆栈, 这是一个示例:

Stack(
              children: [
                Container(
                  height: 300,
                  width: 300,
                  child: Image.asset(
                    "assets/Image.png",
                    fit: BoxFit.cover,
                  ),
                ),
                Positioned(
                    top: 10,
                    child: ElevatedButton(
                      onPressed: () {},
                      child: Text("Button 1"),
                    )),
                Positioned(
                    bottom: 10,
                    child: ElevatedButton(
                      onPressed: () {},
                      child: Text("Button 2"),
                    ))
              ],
            )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多