implicitView property
The FlutterView provided by the engine if the platform is unable to create windows, or, for backwards compatibility.
If the platform provides an implicit view, it can be used to bootstrap the framework. This is common for platforms designed for single-view applications like mobile devices with a single display.
Applications and libraries must not rely on this property being set as it may be null depending on the engine's configuration. Instead, consider using View.of to lookup the FlutterView the current BuildContext is drawing into.
While the properties on the referenced FlutterView may change, the reference itself is guaranteed to never change over the lifetime of the application: if this property is null at startup, it will remain so throughout the entire lifetime of the application. If it points to a specific FlutterView, it will continue to point to the same view until the application is shut down (although the engine may replace or remove the underlying backing surface of the view at its discretion).
See also:
- View.of, for accessing the current view.
- PlatformDispatcher.views for a list of all FlutterViews provided by the platform.
Implementation
FlutterView? get implicitView {
final FlutterView? result = _views[_implicitViewId];
// Make sure [implicitView] agrees with `_implicitViewId`.
assert((result != null) == (_implicitViewId != null),
(_implicitViewId != null) ?
'The implicit view ID is $_implicitViewId, but the implicit view does not exist.' :
'The implicit view ID is null, but the implicit view exists.');
// Make sure [implicitView] never chages.
assert(() {
if (_debugRecordedLastImplicitView) {
assert(identical(_debugLastImplicitView, result),
'The implicitView has changed:\n'
'Last: $_debugLastImplicitView\nCurrent: $result');
} else {
_debugLastImplicitView = result;
_debugRecordedLastImplicitView = true;
}
return true;
}());
return result;
}