runApp function

void runApp(
  1. StatelessWidget widgetBuilder(
    1. Map<String, String> args
    ), {
  2. @Deprecated('Use [target] instead') String? targetId,
  3. Element? target,
})

Creates a new app and appends it to the target HTML element. The args contain all attributes of the HTML element.

Implementation

void runApp(
  StatelessWidget Function(Map<String, String> args) widgetBuilder, {
  @Deprecated('Use [target] instead') String? targetId,
  Element? target,
}) {
  targetId ??= 'app';
  target ??= document.getElementById(targetId);
  if (target == null) {
    throw Exception('There is no element with the ID $targetId in the DOM!');
  }
  _appNode = target;

  // Set the context of the root widget
  final rootWidget = widgetBuilder(_appNode.dataset);
  final context = BuildContext();

  rootWidget.inflate(context);

  // Build and mount it
  _appNode.children = [context.element!];

  // We added elements to the grid, we can now execute callbacks.
  context.executeCallbacks();
}