Flutter · colveor_ui

ColveorApp

ColveorApp creates the ProviderScope, provides your config and routes, and initializes responsive sizing.

Setup

main.dart
Dart
import 'package:flutter/material.dart';
import 'package:colveor_ui/colveor_ui.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final config = AppConfig();
  await VoBootstrap.initialize(config: config);

  runApp(
    ColveorApp(
      config: config,
      appRoutes: appRoutes,
      builder: (context, colveor) => App(colveor: colveor),
    ),
  );
}

class App extends StatelessWidget {
  const App({super.key, required this.colveor});

  final ColveorRef colveor;

  @override
  Widget build(BuildContext context) => MaterialApp.router(
    title: 'My App',
    theme: AppTheme().light,
    darkTheme: AppTheme().dark,
    themeMode: colveor.themeMode,
    routerConfig: colveor.router,
  );
}

Parameters

NameDescription
configRequired. Your VoConfig.
appRoutesRequired. List<RouteBase> Function(VoConfig) — your go_router routes.
builderRequired. Builds your MaterialApp; receives a ColveorRef.
overridesExtra Riverpod overrides, applied after the config and routes. Default [].
observersRiverpod ProviderObservers.
designSizeThe screen size designs are drawn at. Default Size(360, 690).
minTextAdaptScale text by the smaller of the width and height ratios. Default true.
splitScreenModeAdapt sizes for split-screen and multi-window. Default true.
Dart
ColveorApp(
  config: config,
  appRoutes: appRoutes,
  designSize: const Size(390, 844),
  builder: (context, colveor) => App(colveor: colveor),
)

ColveorRef

NameDescription
routerThe GoRouter built from your routing config.
themeModeThe current ThemeMode (rebuilds when it changes).
navigatorKeyThe root navigator key (voNavigatorKey).
setThemeMode(mode)Change and persist the theme mode.
toggleThemeMode()Switch between light and dark.

VoBootstrap

VoBootstrap.initialize(config:, preloadCountries: false) runs startup work before runApp. Pass preloadCountries: true to load the country list used by the phone input up front; otherwise it loads the first time a phone input is built.

Testing

Dart
await tester.pumpWidget(
  ColveorApp(
    config: AppConfig(),
    appRoutes: appRoutes,
    builder: (context, colveor) => App(colveor: colveor),
  ),
);
await tester.pumpAndSettle();

To test a single widget, wrap it in ScreenUtilPlusInit and a MaterialApp using your theme — widgets that read VoSizes need ScreenUtil above them.