set the value of Image to nil SwiftUI

Viewed 304

I have set a condition to load an SFsymbol.

Image(systemname : isShowList ? "ellipsis" : "")

But I am getting a warning No symbol named ''

How can I set this to an empty value without warning?

1 Answers

It might depend on what is needed in common layout, but possible variants are

a) remove image conditionally

if isShowList {
   Image(systemName : "ellipsis")
}

b) hide image conditionally

Image(systemName : "ellipsis")
  .opacity(isShowList ? 1.0 : 0.0)
Related