PlatformViewGuard class
Guards platform-view creation during app startup / hot-restart.
On iOS, FlutterPlatformViewsController may retain residual view
registrations from a previous Dart isolate immediately after a hot
restart. If the new isolate's widgets request platform-view creation
before the engine has fully purged these stale registrations, it
rejects them with PlatformException(recreating_view, ...).
This guard delays platform-view widgets by a short fixed duration (500 ms) after the first widget requests readiness, giving the engine ample time to run its internal cleanup. The delay fires only once per app lifetime — subsequent checks are instantaneous.
Usage inside component build methods:
if (!PlatformViewGuard.isReady) {
PlatformViewGuard.ensureScheduled();
return _fallbackWidget();
}
return UiKitView(...);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- isReady → bool
-
Whether it is safe to create platform views.
no setter
-
readyNotifier
→ ValueNotifier<
bool> -
Notifier that fires once when readiness flips to
true.final
Static Methods
-
ensureScheduled(
) → void - Schedules the readiness flip if it hasn't been scheduled yet.