Dynamic WidgetConfiguration

Hi,

Is there a way I can pass StaticConfiguration or IntentConfiguration depending upon some conditions?

right now it gives build error:

Function declares an opaque return type, but the return statements in its body do not have matching underlying types


var body: some WidgetConfiguration {
    if condition {
      return IntentConfiguration(kind: kind, intent: MyIntent.self, provider: Provider()) { entry in
        MyWidgetEntryView(entry: entry)
      }
      .configurationDisplayName("")
      .description("")
      .supportedFamilies([.systemLarge])
    } else {
      return StaticConfiguration(kind: kind, provider: MyProvider()) { entry in
        MyWidgetEntryView(entry: entry)
      }.configurationDisplayName("")
      .description("")
      .supportedFamilies([.systemLarge])
    }
  }

I know this has to do with opaque return type, but is there a way to achieve this?


It would be good if Apple adds @WidgetConfigurationBuilder in future iOS 14 versions, to support the above behaviour
Dynamic WidgetConfiguration
 
 
Q