window top-level property

  1. @Deprecated('Look up the current FlutterView from the context via View.of(context) or consult the PlatformDispatcher directly instead. ' 'Deprecated to prepare for the upcoming multi-window support. ' 'This feature was deprecated after v3.7.0-32.0.pre.')
SingletonFlutterWindow window
final

Deprecated. Will be removed in a future version of Flutter.

This global property is deprecated to prepare for Flutter's upcoming support for multiple views and multiple windows.

It represents the main view for applications where there is only one view, such as applications designed for single-display mobile devices. If the embedder supports multiple views, it points to the first view created which is assumed to be the main view. It throws if no view has been created yet or if the first view has been removed again.

The following options exists to migrate code that relies on accessing this deprecated property:

If a BuildContext is available, consider looking up the current FlutterView associated with that context via View.of. It gives access to the same functionality as this deprecated property. However, the platform-specific functionality has moved to the PlatformDispatcher, which may be accessed from the view returned by View.of via FlutterView.platformDispatcher. Using View.of with a BuildContext is the preferred option to migrate away from this deprecated window property.

If no context is available to look up a FlutterView, the PlatformDispatcher can be used directly for platform-specific functionality. It also maintains a list of all available FlutterViews in PlatformDispatcher.views to access view-specific functionality without a context. If possible, consider accessing the PlatformDispatcher via the binding (e.g. WidgetsBinding.instance.platformDispatcher) instead of the static singleton PlatformDispatcher.instance. See PlatformDispatcher.instance for more information about why this is preferred.

See also:

Implementation

@Deprecated(
  'Look up the current FlutterView from the context via View.of(context) or consult the PlatformDispatcher directly instead. '
  'Deprecated to prepare for the upcoming multi-window support. '
  'This feature was deprecated after v3.7.0-32.0.pre.'
)
final SingletonFlutterWindow window = SingletonFlutterWindow._();