window property Null safety
The main window to which this binding is bound.
A number of additional bindings are defined as extensions of BindingBase, e.g., ServicesBinding, RendererBinding, and WidgetsBinding. Each of these bindings define behaviors that interact with a ui.SingletonFlutterWindow.
Each of these other bindings could individually access a ui.SingletonFlutterWindow statically, but that would preclude the ability to test its behaviors with a fake window for verification purposes. Therefore, BindingBase exposes this ui.SingletonFlutterWindow for use by other bindings. A subclass of BindingBase, such as TestWidgetsFlutterBinding, can override this accessor to return a different ui.SingletonFlutterWindow implementation, such as a TestWindow.
The window
is a singleton meant for use by applications that only have a
single main window. In addition to the properties of ui.FlutterWindow,
window
provides access to platform-specific properties and callbacks
available on the platformDispatcher.
For applications designed for more than one main window, prefer using the platformDispatcher to access available views via ui.PlatformDispatcher.views.
However, multiple window support is not yet implemented, so currently this provides access to the one and only window.
Implementation
// TODO(gspencergoog): remove the preceding note once multi-window support is
// active.
ui.SingletonFlutterWindow get window => ui.window;