@@ -118,6 +118,9 @@ class PlatformDispatcher {
118118 /// these. Use [instance] to access the singleton.
119119 PlatformDispatcher ._() {
120120 _setNeedsReportTimings = _nativeSetNeedsReportTimings;
121+ if (_implicitViewEnabled) {
122+ _doAddView (_kImplicitViewId);
123+ }
121124 }
122125
123126 /// The [PlatformDispatcher] singleton.
@@ -225,18 +228,8 @@ class PlatformDispatcher {
225228 /// * [PlatformDispatcher.views] for a list of all [FlutterView] s provided
226229 /// by the platform.
227230 FlutterView ? get implicitView {
228- if (_implicitViewEnabled ()) {
229- if (_implicitView == null ) {
230- _addView (_kImplicitViewId);
231- }
232- return _implicitView! ;
233- }
234- return null ;
231+ return _views[_kImplicitViewId];
235232 }
236- FlutterView ? _implicitView;
237-
238- @Native < Handle Function ()> (symbol: 'PlatformConfigurationNativeApi::ImplicitViewEnabled' )
239- external static bool _implicitViewEnabled ();
240233
241234 /// A callback that is invoked whenever the [ViewConfiguration] of any of the
242235 /// [views] changes.
@@ -265,22 +258,23 @@ class PlatformDispatcher {
265258 }
266259
267260 FlutterView _createView (int id) {
268- if (id == _kImplicitViewId) {
269- assert (_implicitViewEnabled ());
270- return _implicitView ?? = FlutterView ._(id, this );
271- }
272261 return FlutterView ._(id, this );
273262 }
274263
275264 void _addView (int id) {
276- assert (! _views.containsKey (id));
265+ assert (id != _kImplicitViewId, 'The implicit view #$id can not be added.' );
266+ _doAddView (id);
267+ }
268+
269+ void _doAddView (int id) {
270+ assert (! _views.containsKey (id), 'View ID $id already exists.' );
277271 _views[id] = _createView (id);
278272 _viewConfigurations[id] = const _ViewConfiguration ();
279273 }
280274
281275 void _removeView (int id) {
282- assert (! _views. containsKey (id) );
283- // TODO(dkwingsmt): Reset _implicitView?
276+ assert (id != _kImplicitViewId, 'The implicit view #$ id can not be removed.' );
277+ assert (_views. containsKey (id), 'View ID $ id does not exist.' );
284278 _views.remove (id);
285279 _viewConfigurations.remove (id);
286280 }
0 commit comments