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,
})| Name | Description |
|---|---|
config | Your app's VoConfig (the colveor one). |
preloadCountries | Load the phone-input country list up front instead of on first use. |
backgroundMessageHandler | Top-level FCM handler for messages received while the app is in the background. |
configureDio | Adjust the Dio client (adapter, timeouts). To add interceptors, use VoConfig.interceptorHooks instead. |
What it does
- Runs the colveor_ui bootstrap (country preloading when requested).
- Registers the background message handler, then initializes Firebase when
config.firebaseConfigis set. Missing or placeholder options (values starting withYOUR_) skip Firebase with a warning; errors are logged, never thrown. - Creates the auth session, the DPoP key store (when
enableDpopis true) and the shared Dio client, then appliesconfigureDio.
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
| Name | Description |
|---|---|
VoBootstrap.onMessage | Stream<RemoteMessage> of messages received while the app is in the foreground. |
VoBootstrap.onMessageOpenedApp | Stream<RemoteMessage> fired when the user taps a notification that opens the app. |