'SwiftUI List row color inconsistent while scrolling in a NavigationView

The background color of row views within a List inside a NavigationView inconsistently switch from transparent to white as I scroll.

enter image description here



Solution 1:[1]

Use

@Environment(\.colorScheme) var colorScheme

struct YourView: View {

    var body: some View {
        Text("Your views")
        .listRowBackground(
            colorScheme == .light ? Color.white : Color(white: 0.09, opacity: 1)
        )
    }
}

colorScheme is necessary to support dark mode.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1