【问题标题】:How to Display a Widget Over the Screen in flutter?如何在颤动的屏幕上显示一个小部件?
【发布时间】:2021-11-26 12:15:31
【问题描述】:

我想在图像/屏幕上显示这样的小部件:

我尝试使用以下代码使用小吃吧:

SnackBar(
  elevation: 5,
  padding: const EdgeInsets.all(0),
  backgroundColor: Colors.transparent,
  behavior: SnackBarBehavior.floating,
  content: Children()

但它在背景中显示了一点黑色......

还有其他小部件可以实现这个吗???

如果你知道问题的答案,那就回答这个问题……

【问题讨论】:

    标签: flutter user-interface flutter-layout snackbar


    【解决方案1】:

    在这种情况下,您也可以使用 Toast。 Toast 通常会显示 2 秒,您也可以设置自定义持续时间。

    Flutter Toast 是一个很好的库来实现同样的目标。

    https://pub.dev/packages/fluttertoast

    【讨论】:

      【解决方案2】:
      Stack(children: [
          ImageWidget(...),
          Align(
              alignment: Alignment.bottomCenter
              child: SnackBar(
                  elevation: 5,
                  padding: const EdgeInsets.all(0),
                  backgroundColor: Colors.transparent,
                  behavior: SnackBarBehavior.floating,
                  content: Children()
      )])
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-01
      • 2021-10-22
      • 1970-01-01
      • 2021-10-30
      • 2014-09-29
      • 1970-01-01
      • 2019-05-07
      相关资源
      最近更新 更多