Flutter · colveor

Bootstrap

VoBootstrap prepares Firebase, the Dio client and the auth session. Await it before calling runApp.

VoBootstrap.initialize

Dart
static Future<void> initialize({
  required VoConfig config,
  bool preloadCountries = false,
  Future<void> Function(RemoteMessage)? backgroundMessageHandler,
  void Function(Dio dio)? configureDio,
})
NameDescription
configYour app's VoConfig (the colveor one).
preloadCountriesLoad the phone-input country list up front instead of on first use.
backgroundMessageHandlerTop-level FCM handler for messages received while the app is in the background.
configureDioAdjust the Dio client (adapter, timeouts). To add interceptors, use VoConfig.interceptorHooks instead.

What it does

  1. Runs the colveor_ui bootstrap (country preloading when requested).
  2. Registers the background message handler, then initializes Firebase when config.firebaseConfig is set. Missing or placeholder options (values starting with YOUR_) skip Firebase with a warning; errors are logged, never thrown.
  3. Creates the auth session, the DPoP key store (when enableDpop is true) and the shared Dio client, then applies configureDio.

main.dart

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

@pragma('vm:entry-point')
Future<void> _onBackgroundMessage(RemoteMessage message) async {}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await VoBootstrap.initialize(
    config: AppConfig(),
    backgroundMessageHandler: _onBackgroundMessage,
  );

  runApp(
    ColveorApp(
      config: AppConfig(),
      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(
    theme: const AppTheme().light,
    darkTheme: const AppTheme().dark,
    themeMode: colveor.themeMode,
    routerConfig: colveor.router,
  );
}

Tip

ColveorApp comes from colveor_ui — see ColveorApp for all of its options. The config you pass must extend colveor's VoConfig, otherwise reading it throws a StateError.

Message streams

NameDescription
VoBootstrap.onMessageStream<RemoteMessage> of messages received while the app is in the foreground.
VoBootstrap.onMessageOpenedAppStream<RemoteMessage> fired when the user taps a notification that opens the app.