A DOM form inside a Flutter web app

Flutter draws every widget itself with CanvasKit, so a Flutter web app has no real inputs apart from one hidden text field. This app shows a real <form> with an <input>, a <select> and a <textarea> as one of its widgets. Flutter gets the form's pixels through createImageFromTextureSource() in dart:ui_web and rotates, tilts, fades and blurs them with its own widgets. The browser still handles the form's input. Load the app, type in the form, then move the Flutter sliders.

Flutter 3.50.1 with CanvasKit, served from this site. It isn't loaded until you ask.

No measurements yet.

The text field and the four sliders at the top are Flutter widgets. The form below them is the DOM form: the caret, the selection, the keyboard on a phone, autofill and the native select picker are the browser's. The yellow badge is a Flutter widget drawn over the form. The second design restarts the page with a different engine setting.

Show the code a DOM form as a Flutter widget
  1. The form is a child of a 2D canvas that sits over the Flutter view.
  2. The canvas is invisible and still takes input.
  3. JavaScript: on each paint event, draw the form into the canvas and wake Flutter.
  4. JavaScript: what Flutter is given. Three ways of handing over the same canvas.
  5. Dart: the interface to the page.
  6. Dart: canvas to ui.Image. One createImageFromTextureSource() call per paint event.
  7. Dart: the widget. Flutter sets the width, the browser answers with the height, and a RawImage shows the pixels.
  8. Dart: the widget in a scene. Transform, Opacity and ImageFiltered apply to it like any widget.
  9. Dart: report where the widget was drawn.
  10. JavaScript: put the real form there. Flutter's matrix becomes a CSS matrix3d() on the canvas.
  11. JavaScript: layout.
  12. The second design: the form inside Flutter's canvas. Flutter is given the form itself, and one texImage2D() call is replaced by texElementSubImage2D().
  13. Starting Flutter in a host element.
  14. Loading it on request.
  15. All of main.dart.
  16. All of bridge.js.

How it works

createImageFromTextureSource() makes a ui.Image from an image, a video, a canvas, an ImageBitmap or a VideoFrame. It doesn't take an element, so the page needs something that turns the form into one of those. Two designs do that here.

Live checks

The checks load two more copies of the Flutter app in a small frame, one for each design, so they don't touch the one above. They take about 20 seconds.

ResultExperimentDetail

Findings

Measured in headless Chromium 157 on 2026-11-21 with software rendering, at 1× and at a 2.625 device scale with touch. Flutter 3.50.1, Dart 3.14.0.