runApp function

void runApp({
  1. required FeaturesBuilder features,
  2. LazyFeaturesBuilder? lazyFeatures,
  3. PluginDescriptor? plugins,
  4. PlatformWidgetBuilder? platformWidgetBuilder,
  5. String? initialLocation,
  6. String? homeLocation,
  7. bool captureErrors = true,
  8. AppRunner? appRunner,
})

The main entry point to kick off the Vyuh Application. This function should be called from the main function of the application. It initializes the Vyuh Platform and runs the application with given features and plugins.

  • features: A builder function that returns a list of FeatureDescriptor objects. These are loaded eagerly at startup.
  • lazyFeatures: Optional. A builder function that returns a list of LazyFeatureDescriptor objects. These are loaded on-demand when their routes are first navigated to, enabling web code splitting via Dart's deferred as imports.
  • plugins: Optional. A PluginDescriptor object that specifies the plugins to be used. If not provided, defaults to PluginDescriptor.system.
  • platformWidgetBuilder: Optional. A builder function that returns a platform-specific widget. If not provided, defaults to defaultPlatformWidgetBuilder.
  • initialLocation: Optional. The initial location to open in the app.
  • homeLocation: Optional. Where error views send the user with "Go home". Defaults to initialLocation, then /.
  • captureErrors: Optional, defaults to true. Routes uncaught Flutter and platform errors to telemetry and, in release builds, shows a themed placeholder for widgets that fail to build.
  • appRunner: Optional. A custom AppRunner function to control how the app is launched. This allows integrating with packages like scaled_app, device_preview, or custom error zone wrapping. If not provided, defaults to defaultAppRunner.

Implementation

void runApp({
  required FeaturesBuilder features,
  LazyFeaturesBuilder? lazyFeatures,
  PluginDescriptor? plugins,
  PlatformWidgetBuilder? platformWidgetBuilder,
  String? initialLocation,
  String? homeLocation,
  bool captureErrors = true,
  AppRunner? appRunner,
}) async {
  final widgetBuilder = platformWidgetBuilder ?? PlatformWidgetBuilder.system;

  vyuh = _DefaultVyuhPlatform(
    featuresBuilder: features,
    lazyFeaturesBuilder: lazyFeatures,
    pluginDescriptor: plugins ?? PluginDescriptor.system,
    widgetBuilder: widgetBuilder,
    initialLocation: initialLocation,
    homeLocation: homeLocation,
    captureErrors: captureErrors,
    appRunner: appRunner ?? defaultAppRunner,
  );

  vyuh.run();
}