为什么我的Flutter代码不起作用?

huangapple go评论58阅读模式
英文:

Can someone please explain why my flutter code doesn't work

问题

以下是您要翻译的代码部分:

Column(
  children: <Widget>[
    SizedBox(height: 10),
    Text(
      "No Transactions Yet!!",
      style: Theme.of(context).textTheme.headline6,
    ),
    SizedBox(
      height: 20,
    ),
    Container(
      alignment: Alignment(0, 0),
      height: 240,
      child: Image.asset('assets/images/wait.png', fit: BoxFit.cover),
    ),
  ],
)

另外,请注意,您在尝试修复图片显示的问题时提供了以下代码:

Container(
  decoration: BoxDecoration(
    image: DecorationImage(
      image: AssetImage("assets/images/wait.jpg"),
      fit: BoxFit.cover,
    ),
  ),
)

如果您还有其他问题或需要更多帮助,请随时提出。

英文:
                children: &lt;Widget&gt;[
                  SizedBox(height: 10),
                  Text(
                    &quot;No Transactions Yet!!&quot;,
                    style: Theme.of(context).textTheme.headline6,
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Container(
                    alignment: Alignment(0, 0),
                    height: 240,
                    child: Image.asset(&#39;assets/images/wait.png&#39;,
                        fit: BoxFit.cover),
                  ),
                ],
              )

this is a part of my flutter code, I have downloaded a png file and edited that picture so that it can have white background, now my problem is, it is not getting matched with the background of my App's Background (background color is white) . It is like a pasted picture onto the screen . How to fix this.
I am giving the picture try to see that in different directions so that you can understand my problem.
enter image description here

I have tried like this

Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage(&quot;assets/images/wait.jpg&quot;),
            fit: BoxFit.cover,
          ),
        ),

here the photo was zoomed in.

答案1

得分: 1

更改背景颜色为Color(0xffffffff)

Scaffold(
  backgroundColor: Color(0xffffffff),
  body:.....
)
英文:

seems now ur background color is Color(0xfffefefe) change it to Color(0xffffffff)

 Scaffold(
        backgroundColor: Color(0xffffffff),
      body:.....
    )

答案2

得分: 1

你需要将你的 Scaffold 背景颜色设置为 Colors.white。

Scaffold(
  backgroundColor: Colors.white,
  body: Column(
    children: <Widget>[
      SizedBox(height: 10),
      Text(
        "No Transactions Yet!!",
        style: Theme.of(context).textTheme.headline6,
      ),
      SizedBox(
        height: 20,
      ),
      Container(
        alignment: Alignment(0, 0),
        height: 240,
        child: Image.asset('assets/images/wait.png', fit: BoxFit.cover),
      ),
    ],
  ),
)
英文:

For this you need to set your Scaffold background color to Colors.white.

Scaffold(
 backgroundColor: Colors.white
 body: Column(
    children: &lt;Widget&gt;[
     SizedBox(height: 10),
     Text(
       &quot;No Transactions Yet!!&quot;,
      style: Theme.of(context).textTheme.headline6,
     ),
     SizedBox(
       height: 20,
     ),
     Container(
       alignment: Alignment(0, 0),
       height: 240,
       child: Image.asset(&#39;assets/images/wait.png&#39;,
        fit: BoxFit.cover),
     ),
   ],
 )

)

答案3

得分: 1

更改脚手架的背景颜色为白色。

英文:

change the background color to white in scaffold

huangapple
  • 本文由 发表于 2023年5月17日 10:32:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76268217.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定