ios – Display of @Environment(\.description) behaves inconsistently

0
21

[ad_1]

The following code was written to display a single string (6000 chars) of environment values:

struct ContentView: View {
    
    @Environment(\.description) var description
    
    var body: some View {
        VStack {
            Text("@Environment Values").font(.title)
            
            ScrollView {
                Text("\(description)").font(.caption)
            }.padding()
        }
    }
}

The result is inconsistent on both simulator and iPhone. When run, sometimes the information is displayed as desired on the left but often no values are displayed as shown on the right:
enter image description here

Other things tried didn’t resolve the problem. Placing the environment variable in a viewmodel gives the message “Accessing Environment’s value outside of being installed on a View. This will always read the default value and will not update.”

Splitting the string into two strings gives the same inconsistent results.

Is this a thread issue?
Outside of listing every environment key and value, can anything be done to display the @Environment(.description) consistently?

[ad_2]