platform property
The platform adaptive widgets should adapt to target and mechanics too.
Same property as in ThemeData factory. Included for convenience to avoid a copyWith to change it.
Defaults to the current platform, as exposed by defaultTargetPlatform. This should be used in order to style UI elements according to platform conventions.
Widgets from the material library should use this getter (via Theme.of)
to determine the current platform for the purpose of emulating the
platform behavior (e.g. scrolling or haptic effects). Widgets and render
objects at lower layers that try to emulate the underlying platform
platform can depend on defaultTargetPlatform directly, or may require
that the target platform be provided as an argument. The
dart.io.Platform
object should only be used directly when it's critical
to actually know the current platform, without any overrides possible (for
example, when a system API is about to be called).
In a test environment, the platform returned is TargetPlatform.android regardless of the host platform. (Android was chosen because the tests were originally written assuming Android-like behavior, and we added platform adaptations for other platforms later). Tests can check behavior for other platforms by setting the platform of the Theme explicitly to another TargetPlatform value, or by setting debugDefaultTargetPlatformOverride.
Implementation
final TargetPlatform? platform;