Overview
The common widgets library (lib/ui/common/) provides reusable components used throughout the Wonderous app. These include controls, layout utilities, visual effects, and helper widgets.
Controls
AppBtn
Location:lib/ui/common/controls/buttons.dart
The core button component with multiple variants and customization options.
Basic Usage:
onPressed- Callback function (VoidCallback?)semanticLabel- Accessibility label (required)child- Button content widgetpadding- Internal padding (EdgeInsets?)expand- Fill available width (bool)isSecondary- Use secondary color scheme (bool)circular- Circular shape (bool)minimumSize- Minimum button dimensions (Size?)bgColor- Background color (Color?)border- Border style (BorderSide?)pressEffect- Enable press animation (bool)hoverEffect- Enable hover effect (bool)enableFeedback- Haptic feedback (bool)focusNode- Focus management (FocusNode?)
- Press effect: 0.7 opacity on tap
- Hover effect: White overlay with 30 alpha (web only)
- Focus indicator: Accent color border when focused
CircleBtn / CircleIconBtn
Location:lib/ui/common/controls/circle_buttons.dart
Circular buttons for icons and actions.
CircleIconBtn:
- Automatic navigation handling if onPressed is null
- ESC key support for closing
- Safe area padding with
.safe()method
AppHeader
Location:lib/ui/common/controls/app_header.dart
Standard app header with title, subtitle, and back button.
Usage:
title- Main title text (String?)subtitle- Secondary text below title (String?)showBackBtn- Display back button (bool)isTransparent- Transparent background (bool)onBack- Custom back action (VoidCallback?)backIcon- Custom back icon (AppIcons)backBtnSemantics- Back button accessibility label (String?)trailing- Widget on right side (WidgetBuilder?)
- Fixed height: 64px (scaled)
- Safe area at top
- Title/subtitle centered
- Back button on left, trailing on right
AppPageIndicator
Location:lib/ui/common/controls/app_page_indicator.dart
Page indicator dots for PageView navigation.
Usage:
count- Number of pages (int)controller- PageController to track (required)onDotPressed- Callback when dot tapped (Function(int)?)color- Dot color (Color?)dotSize- Dot diameter in pixels (double?)semanticPageTitle- Accessibility page title (String)
- Expanding dots effect (2x expansion)
- Live region announcements for screen readers
- Auto-updates based on PageController
Other Controls
AppImage - Enhanced image widget with loading states AppLoadingIndicator - Consistent loading spinner Checkbox - Custom styled checkbox DiagonalTextPageIndicator - Alternative page indicator EightWaySwipeDetector - Multi-directional swipe detection LocaleSwitcher - Language selection control ScrollDecorator - Styled scrollbars TrackpadListener - Trackpad/mouse scroll detectionLayout Widgets
CenteredBox
Location:lib/ui/common/centered_box.dart
Centers content with optional size constraints.
Usage:
GradientContainer
Location:lib/ui/common/gradient_container.dart
Container with linear gradient background.
Base Class:
LazyIndexedStack
Location:lib/ui/common/lazy_indexed_stack.dart
IndexedStack that only builds children when first shown.
Usage:
- Lazy initialization of tab content
- Maintains state of previously shown children
- Better performance than always building all children
Visual Effects
BlendMask
Location:lib/ui/common/blend_mask.dart
Applies blend modes to child widget using render objects.
Usage:
blendModes- List of blend modes to apply (List<BlendMode>)opacity- Overall opacity (double)child- Widget to apply effects to (required)
FadeColorTransition
Location:lib/ui/common/fade_color_transition.dart
Animated color transition for backgrounds.
Usage:
CompassDivider
Location:lib/ui/common/compass_divider.dart
Decorative divider with compass rose styling.
DashedLine
Location:lib/ui/common/dashed_line.dart
Customizable dashed line widget.
Usage:
Modals
Modal System
Location:lib/ui/common/modals/app_modals.dart
Show Modal:
Utilities
IgnorePointerAndSemantics
Location:lib/ui/common/ignore_pointer.dart
Combines IgnorePointer and ExcludeSemantics.
Usage:
MeasurableWidget
Location:lib/ui/common/measurable_widget.dart
Reports widget size changes via callback.
Usage:
StaticTextScale
Location:lib/ui/common/static_text_scale.dart
Locks text scale factor to prevent user scaling.
ThemedText
Location:lib/ui/common/themed_text.dart
Text widgets with consistent theming:
Collectibles
CollectibleItem
Location:lib/ui/common/collectible_item.dart
Displays a collectible with state (locked/discovered/explored).
HiddenCollectible
Location:lib/ui/common/hidden_collectible.dart
Tappable hidden collectible scattered throughout the app.
Input Handling
FullscreenKeyboardListener
Location:lib/ui/common/fullscreen_keyboard_listener.dart
Global keyboard event handling.
Usage:
KeyboardArrowsListener
Location:lib/ui/common/keyboard_arrows_listener.dart
Arrow key navigation support.
App-Specific Widgets
AppIcons
Location:lib/ui/common/app_icons.dart
Enum and widgets for app icon set.
Usage:
AppBackdrop
Location:lib/ui/common/app_backdrop.dart
Consistent backdrop filter effects.
AppScrollBehavior
Location:lib/ui/common/app_scroll_behavior.dart
Custom scroll physics and behavior.
AppShortcuts
Location:lib/ui/common/app_shortcuts.dart
Keyboard shortcuts configuration.
Best Practices
Button Usage
- Always provide
semanticLabelfor accessibility - Use
AppBtn.fromfor common text+icon buttons - Use
AppBtn.basicfor transparent/minimal buttons - Enable
pressEffectandhoverEffectfor better UX
Layout
- Use
CenteredBoxfor max-width content containers - Use
LazyIndexedStackfor tab views - Apply
RepaintBoundaryto animated sections
Accessibility
- Wrap decorative elements in
IgnorePointerAndSemantics - Use semantic labels on all interactive widgets
- Test with screen readers (TalkBack/VoiceOver)
Performance
- Use
constconstructors where possible - Apply
RepaintBoundaryto frequently repainted widgets - Lazy load expensive content
Related
- Screens - Main application screens
- Wonder Illustrations - Illustration components
- Theming - Theme and design tokens