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
| Name | Description |
|---|---|
config | Required. Your VoConfig. |
appRoutes | Required. List<RouteBase> Function(VoConfig) — your go_router routes. |
builder | Required. Builds your MaterialApp; receives a ColveorRef. |
overrides | Extra Riverpod overrides, applied after the config and routes. Default []. |
observers | Riverpod ProviderObservers. |
designSize | The screen size designs are drawn at. Default Size(360, 690). |
minTextAdapt | Scale text by the smaller of the width and height ratios. Default true. |
splitScreenMode | Adapt 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
| Name | Description |
|---|---|
router | The GoRouter built from your routing config. |
themeMode | The current ThemeMode (rebuilds when it changes). |
navigatorKey | The 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.