How to return a dynamic list of widgets in SwiftUI WidgetBundleBuilder body

Viewed 918

Is it possible to create a dynamic list of widgets inside the body of WidgetBundle? For example:

@main
struct HomeWidgetBundle: WidgetBundle {
    
    @WidgetBundleBuilder
    var body: some Widget {
        
        List<Widget> {
            ForEach (0..<10) {index in
                 HomeWidget()
            }
        }
    }
}

This above example is just to clarify the question, the code is not compiling.

0 Answers
Related