Latest Post

Flutter Vs React Native which is better? How to adjust SwiftUI text alignment what are tuple in python
selection list of  Particular Row in SwiftUI. Swift Supports both single selection and as well as multiple Selection in List.Swiftui list Selection

Earlier we used to have tableView DidSelect method in Storyboard but now we have list we can add selection of row in Swift.

Swiftui list Selection

To create a Single selection in SwiftUI we needed to declare the variable as vehicleSelected as shown in below code

struct ContentView: View {

    let vehicles = [






    @State private var vehicleSelected: String?

    var body: some View {

        NavigationView {

            List(vehicles, id: .self, selection: $vehicleSelected) { vehicle in



            .navigationTitle("Vehicle Selection")

            .toolbar {






we can select the multiple row by changing the type of vehicleSelected by using Set

@State private var selection = Set<String>()


Leave a Reply

Your email address will not be published.