Platform Views: Embedding Native UI in Flutter
Platform Views cut a hole in your Flutter UI to show a native component. Use them to embed UI that can't be rebuilt in Dart, like Google Maps or a native WebView. Be warned: they are resource-heavy and can hurt performance if overused.
WHY IT EXISTS: Flutter renders its own UI pixels, which is great for cross-platform consistency. However, sometimes you need to use a native component that doesn't have a Dart equivalent, such as a platform's built-in map view, a specialized ad SDK, or a complex, proprietary UI control you can't afford to rewrite. Platform Views were created to bridge this gap.
THE MENTAL MODEL: Imagine your Flutter app is a painting on a canvas. A Platform View is like cutting a precise hole in that canvas and placing a small, live television screen behind it. The TV screen (the native view) plays its own content, independent of the painting, but it's perfectly framed by the hole you cut. You can interact with the TV, and Flutter manages its size and position on the canvas.
HOW IT WORKS: Flutter uses two main strategies. On Android, the default is "Hybrid Composition," which uses a standard Android View and coordinates its placement with the Flutter UI. On iOS, it uses a similar approach with UIView. For more complex cases or older Android versions, "Virtual Display" mode renders the native view to an off-screen texture that Flutter then draws into its scene. This texture-based approach has more performance overhead. Flutter manages passing touch events to the native view and compositing it into the final frame.
WHEN TO USE IT: Use Platform Views when you absolutely must integrate a native UI component. This is common for three scenarios: first, embedding map views (like Google Maps or Apple Maps); second, using a specific WebView implementation; third, integrating a third-party native SDK that provides its own UI (e.g., a payment processor or video player).
WHEN NOT TO USE IT: Avoid Platform Views for UI that can be built with Flutter widgets. They are a performance-heavy "escape hatch," not a standard tool. Each view adds memory and rendering overhead, can complicate input handling (like keyboard focus), and may not participate in Flutter's animations and transformations as smoothly as pure Dart widgets. If a good Dart package exists for your use case, prefer it.
ONE CANONICAL EXAMPLE: A common use case is embedding Google Maps. The google_maps_flutter plugin uses a Platform View. When you add a GoogleMap widget to your app, the plugin instantiates a native MapView on Android or MKMapView on iOS behind the scenes and embeds it in your Flutter layout, allowing you to interact with a fully-featured native map from your Dart code.
Read the original → docs.flutter.dev
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.