Returns
Which keys are set depends on the renderer. iOS setscolorScheme, displayScale, dynamicTypeSize, layoutDirection, and locale. Web sets colorScheme, platform, and screen. The Android renderer (bindjs-android 0.0.33) sets none of them. Read each with a fallback.
An EnvironmentValues object with the following fields:
The user’s preferred text size setting. Not set by every renderer. See DynamicTypeSize.
Opens a URL using the platform’s default handler.
.environment() modifier are also available as additional properties on the returned object.
Usage
Adapt to color scheme
Responsive layout
Read custom environment values
Open a URL
Notes
useEnvironmentmust be called inside a componentbodyfunction, not at the top level.- Custom values are set via the
.environment()modifier on a parent component, e.g..environment("accentColor", "purple"). - The
screendimensions are in logical points, not physical pixels.
See Also
- OpenURLAction — custom URL handling