Flutter,不知道如何解决这些错误。

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

Flutter and don't know how to solve this errors

问题

我希望在按下按钮时,图像会随机出现。

英文:

Flutter,不知道如何解决这些错误。

Flutter,不知道如何解决这些错误。

Flutter,不知道如何解决这些错误。

I wanted images to appear randomly when button is pressed

答案1

得分: 1

在第一张图片中,这只是一个警告,可以通过在你的构造函数中添加 key 来轻松解决这个问题

class RandomImages extends StatefulWidget {
  const RandomImages({super.key}); // 添加这行
  ...
}

对于第二张图片,你可以将一个 Function 作为 onPressed 的值传递

onPressed: () {
  // onPressed 动作
},
英文:

At the first image, it's just warning and this problem can be solved easily by adding key to your contructors

class RandomImages extends StatefulWidget {
  const RandomImages({super.key}); // add this
  ...
}

For second image, you can pass a Function as value of onPressed

onPressed: () {
  // onPressed actions
},

答案2

得分: 0

你需要以正确的方式设置密钥值。

我可以为您更正它,请提供代码作为文本。

英文:

You need to set the key value in proper way

I can correct it for you plz provide me the code as text

huangapple
  • 本文由 发表于 2023年7月13日 16:18:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76677301.html
匿名

发表评论

匿名网友

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

确定