diff --git a/sites/docs/src/content/platform-integration/web/embedding-flutter-web.md b/sites/docs/src/content/platform-integration/web/embedding-flutter-web.md index 2007039155..bfb46fb9d3 100644 --- a/sites/docs/src/content/platform-integration/web/embedding-flutter-web.md +++ b/sites/docs/src/content/platform-integration/web/embedding-flutter-web.md @@ -55,6 +55,63 @@ check out the [Inline Frame element][] docs on MDN. [Inline Frame element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe +### Compare `iframe` and direct DOM embedding {: #compare-iframe-and-dom-embedding } + +When integrating Flutter into an existing web application, +choose between `iframe` embedding and direct DOM embedding +(`hostElement` or multi-view) +based on your isolation, performance, and communication requirements: + +
| Feature | +iframe embedding |
+ Direct DOM embedding (hostElement / multi-view) |
+
|---|---|---|
| Isolation & sandboxing | +Full browser sandboxing with separate JS global scope, DOM tree, + and CSS styles. | +Shares the same DOM tree and JavaScript context. | +
| Memory & engine instances | +Each iframe initializes its own Flutter engine,
+ WebAssembly/JS runtime, and memory heap. |
+ A single Flutter engine instance and memory heap can manage + one or more views (when using multiview). | +
| JavaScript interop | +Communication requires asynchronous messaging
+ (such as postMessage). |
+ Direct synchronous communication using
+ package:web and dart:js_interop. |
+
| Styling & layout | +Independent frame isolated from host page CSS. | +Direct integration into host page CSS layout + (such as flexbox and grid). | +
| State sharing | +State must be synchronized across window boundaries. | +Direct state sharing in Dart across all attached views. | +
| Best for | +Third-party widgets, untrusted content, isolated micro-frontends, + or simple drop-in embeds. | +Embedded UI components in existing web apps, multi-view dashboards, + and tight host-app integration. | +