【问题标题】:Which widget can I use to have like this image? [closed]我可以使用哪个小部件来拥有这样的图像? [关闭]
【发布时间】:2019-04-01 08:56:09
【问题描述】:

我在flutter小部件中搜索了一个和这个相同的小部件,但我没有找到我该怎么做?image with text in bottom

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    试试下面的代码,它的工作和测试

    Center(
              child: Stack(children: <Widget>[
                Image.network(
                    'https://images.pexels.com/photos/433539/pexels-photo-433539.jpeg?cs=srgb&dl=bali-beautiful-beauty-433539.jpg&fm=jpg'),
                Positioned(
                  right: 0,
                  left: 0,
                  bottom: 0,
                  child: Container(
                    alignment: Alignment.center,
                    child: Text(
                      'ImageText',
                      style: TextStyle(color: Colors.white),
                    ),
                    color: Colors.black54,
                    height: 60,
                  ),
                ),
              ]),
            )
    

    【讨论】:

    • 非常感谢您的帮助
    【解决方案2】:

    您可以使用堆栈小部件。这看起来像这样:

    Stack(
      children: <Widget>[
        Image.network('www.somesite.com/some_image_url.png'),
        Container(
          color: Colors.black12
          alignment: Alignment.bottomCenter,
          child: Text('ImageText'),
        ),
      ]
    )
    

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多