【问题标题】:Flutter - Set Image as a background for MaterialFlutter - 将图像设置为材质的背景
【发布时间】:2019-04-01 07:19:26
【问题描述】:

我正在尝试创建一个以图像为背景的return Material

这是我的代码:

    return Material(
        //I tried add this code 
        child: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
              fit: BoxFit.fill,
              image: AssetImage('assets/img1.png'))
        ),
          color: Colors.white,
        //======================
    child: Stack(
            children: <Widget>[
              Container(
              ....
              text("Some text");)
      ]
    )

如何设置return Material的背景?

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    您可以使用容器并在装饰中显示图像

     Material(
        //I tried add this code
        child: Container(
        decoration: BoxDecoration(
            image: DecorationImage(
            fit: BoxFit.fill,
            image: AssetImage('assets/img1.png'))),
        color: Colors.white,
        ))
    

    【讨论】:

    • 我试过了,但是The argument for the named parameter 'child' was already specified
    猜你喜欢
    • 2019-03-25
    • 2022-01-24
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 2015-12-12
    • 1970-01-01
    相关资源
    最近更新 更多