Skip to content

Platform customization ​

PlatformWidgetBuilder holds callbacks for shared platform UI. Customize the defaults with PlatformWidgetBuilder.system.copyWith, then pass the result to runApp.

How the pieces fit together

Customize startup ​

dart
import 'package:material_ui/material_ui.dart';
import 'package:vyuh_core/vyuh_core.dart' as vyuh;

final widgets = vyuh.PlatformWidgetBuilder.system.copyWith(
  appLoader: (_) => const Center(
    child: CircularProgressIndicator(),
  ),
);

// In your app composition:
// vyuh.runApp(features: () => [feature], platformWidgetBuilder: widgets);

The appLoader appears while the platform initializes. errorView receives a required title plus optional error, stack trace, subtitle, retry controls, and a restart flag. Build a useful recovery experience and send diagnostic details to telemetry rather than displaying raw exceptions to users.

Customize the app root ​

appBuilder receives (BuildContext context, VyuhPlatform platform). Return your root app and connect platform.router.instance to its router configuration. This is where the app selects its theme, localization delegates, supported locales, and host-level behavior.

The default root uses Material UI. Customize it with the same package to select an app theme:

dart
final widgets = vyuh.PlatformWidgetBuilder.system.copyWith(
  appBuilder: (_, platform) => MaterialApp.router(
    routerConfig: platform.router.instance,
  ),
);

This uses the Material UI imports from the first fragment. Keep the app root, widgets, themes, and localization delegates from the same package.

The widget builder does not define a buildPage method. Ordinary GoRoute pages own their transitions through pageBuilder and CustomTransitionPage; see routes and navigation.

See the complete PlatformWidgetBuilder API for every callback and its signature.

Migrate existing Material widgets ​

Vyuh uses package:material_ui/material_ui.dart for its Material widgets, themes, and app root. The package provides this Dart migration:

sh
dart fix --apply --code=migrate_design_widgets

Review third-party widget boundaries after the command. A package exposing Flutter Material theme or decoration types may need its generic addon or a neutral binding API rather than an import-only change.