Flutter · colveor_ui

Base Screens

Base State classes give screens direct access to theme, screen size, navigation and toasts.

Base classes

Dart
class _ProfileScreenState extends VoState<ProfileScreen> {
  @override
  Widget build(BuildContext context) =>
      VoButton(label: 'Edit', onPressed: () => push('/profile/edit'));
}

class _OrdersScreenState extends VoConsumerState<OrdersScreen> {
  @override
  void beforeBuild(BuildContext context, WidgetRef ref) {
    // runs before every build
  }

  @override
  Widget buildView(BuildContext context, WidgetRef ref) =>
      Text('Hello', style: typography.titleLarge);
}
NameDescription
VoStateExtends State. Override build as usual.
VoConsumerStateExtends ConsumerState. Override buildView(context, ref), with an optional beforeBuild hook — or override build directly.

Stateless widgets

There is no stateless base class. In a StatelessWidget or ConsumerWidget, use context.vo, which offers the same members:

Dart
VoButton(
  label: 'Save',
  onPressed: () => context.vo.showSuccessToast('Saved'),
)

Available members

NameDescription
Themetheme, colorScheme, flutterTextTheme, colors, sizes, typography, componentTheme, isDarkMode.
ScreenmediaQuery, screenSize, screenWidth, screenHeight, safePadding, isPhone (<600), isTablet (≥600), isDesktop (≥1024).
Navigationrouter, push, pushReplace, pushAndClearStack, pop, currentPath, canPop.
ToastsshowSuccessToast, showErrorToast, showWarningToast, showInfoToast, showToast, dismissAllToasts.
Othermessenger, showSnackBar, unfocus.