Skip to content

Portable widget content

Loading interactive example…Open in new tab ↗
Opening the live canvas…

The live CDX button selects both cards. Show fallback removes its widget registration, revealing the ordinary text layer declared by the shape definition. Show live control restores the interactive button. Both use the same canonical caption; switching presentation does not replace the document or add undo history.

ActionAPIResult
Show fallbacksession.setConfiguration(configuration.copyWith(widgetRegistry: ShapeWidgetRegistry.empty()))Displays registered portable layers instead of native controls.
Show live controlConfigure the widget builder againRestores the button and its selection action.
Download SVG / PNGsession.exportSvg / session.exportPngExports portable content in either presentation mode.

The fallback is required in ShapeWidgetLayerDefinition. It contains ordinary layer definitions, so layout, clipping and output can resolve it without executing Flutter controls. This example shares a canonical text story between the button and fallback. Arbitrary widget-local state is not captured in output; durable content must be represented by canonical data and declared portable layers.

Definition and live control

dart
void showLiveWidget(DrawingSession session, bool live) =>
    session.setConfiguration(
      session.canvasConfiguration.copyWith(
        widgetRegistry: live
            ? exportWidgetRegistry(
                () => session.selectElements(['card-0', 'card-1']),
              )
            : const ShapeWidgetRegistry.empty(),
      ),
    );

Session and presentation switch

Source: fallback.dart.

See widgets and output for the complete contracts.