createAppBar static method
- required BuildContext context,
- required SolidAppBarConfig config,
- WidgetRef? ref,
Creates a generic responsive AppBar with configurable actions.
This method provides a complete AppBar implementation that handles:
- Responsive design (adapts to screen width)
- Action buttons with tooltips
- Overflow menu for narrow screens
- Version display
- Theme toggle
- Proper colour theming
Implementation
static AppBar createAppBar({
required BuildContext context,
required SolidAppBarConfig config,
WidgetRef? ref,
}) {
final theme = Theme.of(context);
final screenWidth = MediaQuery.of(context).size.width;
final isNarrow = screenWidth < config.narrowScreenThreshold;
final isVeryNarrow = screenWidth < config.veryNarrowScreenThreshold;
return AppBar(
title: Text(config.title),
backgroundColor: config.backgroundColor ?? theme.colorScheme.surface,
actions: [
// Version widget - hide on very narrow screens.
if (config.versionConfig != null && !isVeryNarrow)
_buildVersionWidget(config.versionConfig!, isNarrow),
if (config.versionConfig != null && !isVeryNarrow)
const SizedBox(width: 8),
// Regular action buttons.
...config.actions
.where((action) =>
(!isNarrow || !action.hideOnNarrowScreen) &&
(!isVeryNarrow || !action.hideOnVeryNarrowScreen))
.map((action) => _buildActionButton(context, action)),
// Theme toggle - hide on very narrow screens.
if (config.themeConfig?.enabled == true && !isVeryNarrow && ref != null)
_buildThemeToggle(context, config.themeConfig!, ref),
// Overflow menu for narrow screens.
if (isVeryNarrow && config.overflowItems.isNotEmpty)
_buildOverflowMenu(context, config, ref),
],
);
}