简体   繁体   English

flutter 如何在屏幕上显示一个小部件?

[英]How to Display a Widget Over the Screen in flutter?

I want to Display a Widget like this over the Image/Screen:我想在图像/屏幕上显示这样的小部件: 在此处输入图像描述

I try to do this with snackbar with following code:我尝试使用以下代码对 snackbar 执行此操作:

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

But it is displaying with a little black color in background...但它在背景中显示有一点黑色......

Is there any other widget for achieving this???还有其他小部件可以实现这一目标吗???

If you know the answer of the question then answer this question...如果你知道问题的答案然后回答这个问题......

You can also use Toast in this case.在这种情况下,您也可以使用Toast A toast generally appears for 2 seconds or you can set a custom duration for the same. Toast 通常会出现 2 秒,或者您可以为其设置自定义持续时间。

Flutter Toast is a good library to achieve the same. Flutter Toast是实现相同功能的好库。

https://pub.dev/packages/fluttertoast https://pub.dev/packages/fluttertoast

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM