【问题标题】:Inline without else in dart飞镖中没有其他的内联
【发布时间】:2022-11-03 23:37:54
【问题描述】:

我正在尝试在 dart isUser == true && Text("hello") 中不做其他事情,但这给了我一个错误,而如果我在 react native 中这样做,它会有任何帮助

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    你的问题很模糊,但如果我理解你是正确的:

    isUser ? Text("hello") : Text("you are not a user :<"); 
    

    也给自己一些时间看看language tour

    【讨论】:

      【解决方案2】:

      您可以在小部件上使用类似条件的 if

      if (isUser) Text("hello")
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-02-27
        • 1970-01-01
        • 2019-06-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-14
        相关资源
        最近更新 更多