runApp function

void runApp(
  1. Widget app
)

Attaches the given app to the document's body by initializing it.

Note that supporting stateful hot-reload is considered necessary, but this feature has been blocked by Dart's limitations. See https://github.com/flutter/flutter/issues/53041

Implementation

void runApp(final Widget app) {
  if (_appNode == null) {
    // ignore: avoid_print
    print(r'''
  _   _                            _
 | \ | |                          | |
 |  \| | __ ___   ____ _ _ __   __| |
 | . ` |/ _` \ \ / / _` | '_ \ / _` |
 | |\  | (_| |\ V / (_| | | | | (_| |
 |_| \_|\__,_| \_/ \__,_|_| |_|\__,_|

''');

    _addBackEventScript();
  }

  if (_appNode != null && app.matches(_appNode!._widget)) {
    _appNode!._widget = app;
  } else {
    _appNode?._dispose();

    _appNode = app._createNode()
      .._parent = null
      .._initialize();
  }
}