
SmartAppBar - Intelligent Flutter AppBar Widget
A powerful, dynamic, and intelligent SmartAppBar widget for Flutter applications that automatically adapts to routes, supports multiple visual variants, and provides rich accessibility features.
๐ Features
โ Core Functionality
- Automatic Route Detection: Automatically detects current route and applies appropriate configuration
- Multiple Visual Variants: Standard, Glass, Transparent, Bordered, Elevated, Large
- Dynamic Data Integration: Ready for Cubit/Provider integration
- Theme-Aware: Automatic light/dark theme adaptation
- Smooth Animations: Fade, slide, and scale transitions
- Full Accessibility: Screen reader support with semantic labels
๐จ Visual Variants
- Standard: Classic Material 3 design
- Glass: Glass morphism effect with blur and transparency
- Transparent: Fully transparent for overlay scenarios
- Bordered: Subtle border appearance
- Elevated: Prominent shadow and elevation
- Large: Big title app bar for hero sections
๐ฏ Smart Features
- Route-Based Configuration: Automatically changes title, colors, and actions based on route
- Smart Actions: Context-aware action buttons for different screens
- Loading States: Built-in loading indicator support
- Performance Optimized: Caching and efficient rendering
- Customizable: Full parameter override capability
๐ฆ Installation
Add smart_appbar to your pubspec.yaml file:
dependencies:
smart_appbar: ^4.0.0
Then run:
flutter pub get
๐ Quick Start
Basic Usage
import 'package:smart_appbar/smart_appbar.dart';
// Simple usage - everything is automatic
Scaffold(
appBar: const SmartAppBar(), // Automatically detects route and config
body: YourContent(),
);
Route Configuration Examples
The SmartAppBar automatically detects routes and applies appropriate configurations:
// Route-based automatic configuration
MaterialApp(
routes: {
'/home': (context) => const HomeScreen(), // Transparent variant
'/petProfile': (context) => const PetProfileScreen(), // Glass variant
'/settings': (context) => const SettingsScreen(), // Bordered variant
'/profile': (context) => const ProfileScreen(), // Standard variant
'/dashboard': (context) => const DashboardScreen(), // Glass variant
},
home: const HomeScreen(),
);
๐จ Usage Examples
1. Home Screen (Transparent Variant)
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const SmartAppBar(),
// Automatically:
// - Title: "Home ๐ "
// - Variant: Transparent
// - Actions: Notifications + Profile icons
body: YourContent(),
);
}
}
2. Pet Profile (Glass Variant)
class PetProfileScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const SmartAppBar(),
// Automatically:
// - Title: "Pet Profile ๐พ"
// - Variant: Glass with blur effect
// - Actions: Edit + Share icons
body: YourPetContent(),
);
}
}
3. Settings Screen (Bordered Variant)
class SettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const SmartAppBar(),
// Automatically:
// - Title: "Settings โ๏ธ"
// - Variant: Bordered
// - Actions: Search + More icons
body: YourSettingsContent(),
);
}
}
4. Custom Configuration
Scaffold(
appBar: SmartAppBar(
title: 'Custom Title',
variant: SmartAppBarVariant.glass,
centerTitle: true,
actions: [SmartAppBarAction.settings, SmartAppBarAction.search],
backgroundColor: Colors.blue,
enableAnimations: true,
isLoading: true, // Shows loading indicator
),
body: YourContent(),
);
โ๏ธ Configuration
Route Configuration
The SmartAppBar uses a built-in configuration system:
const Map<String, _RouteConfig> _routeConfigs = {
'/home': _RouteConfig(
title: 'Home ๐ ',
variant: SmartAppBarVariant.transparent,
actions: [SmartAppBarAction.notifications, SmartAppBarAction.profile],
),
'/petProfile': _RouteConfig(
title: 'Pet Profile ๐พ',
variant: SmartAppBarVariant.glass,
actions: [SmartAppBarAction.edit, SmartAppBarAction.share],
centerTitle: true,
),
// ... more routes
};
Available Actions
enum SmartAppBarAction {
notifications(Icons.notifications_outlined),
profile(Icons.person_outline),
edit(Icons.edit_outlined),
share(Icons.share_outlined),
settings(Icons.settings_outlined),
search(Icons.search),
more(Icons.more_vert),
add(Icons.add),
favorite(Icons.favorite_border),
bookmark(Icons.bookmark_outline);
}
Available Variants
enum SmartAppBarVariant {
standard, // Classic Material 3 design
glass, // Glass morphism with blur and transparency
transparent, // Fully transparent for overlay scenarios
bordered, // Subtle border appearance
elevated, // Prominent shadow and elevation
large, // Big title app bar for hero sections
}
๐ง Advanced Usage
Custom Theming
SmartAppBar(
title: 'Custom Themed',
backgroundColor: Colors.purple,
foregroundColor: Colors.white,
variant: SmartAppBarVariant.elevated,
elevation: 4.0,
enableGradient: true,
blurIntensity: 0.3,
)
Integration with State Management
// Example with Provider or Cubit
class UserProfileScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SmartAppBar(
// Widget can be extended to work with state management
title: 'Profile: ${user?.name}', // Dynamic from state
isLoading: userCubit.state is UserLoading,
),
body: YourContent(),
);
}
}
๐ฑ Complete Demo App
The widget includes a comprehensive example app that showcases:
- All Route Variants: Home, PetProfile, Settings, Profile, Dashboard screens
- Visual Effects: Different variants in action
- Interactive Elements: Tap actions and navigation
- Theme Adaptation: Light/dark mode support
๐งช Testing
Run the test suite:
flutter test test/
Test coverage includes:
- Route-based configuration
- Custom title override
- Loading state handling
- Action button functionality
- Variant rendering
- Accessibility features
- Edge cases
โฟ Accessibility
- Screen Reader Support: Semantic labels for all interactive elements
- Keyboard Navigation: Full keyboard support
- High Contrast: Automatic contrast adjustment
- Touch Targets: 44x44 minimum touch targets
- Haptic Feedback: Tactile feedback for actions
๐ญ Animations
Built-in animations include:
- Fade In: Smooth opacity transition
- Slide Up: Vertical slide animation
- Scale: Elastic scale effect
- Duration: Customizable animation timing
SmartAppBar(
enableAnimations: true,
animationDuration: const Duration(milliseconds: 300),
)
๐ Dark Mode
Automatic theme adaptation:
- Text colors adjust for readability
- Background colors adapt to theme
- Glass effects work in both modes
- Contrast automatically optimized
๐ Performance
- Caching: Expensive calculations cached
- Efficient Rendering: Minimal rebuilds
- Hardware Accelerated: Uses Flutter's GPU rendering
- Memory Optimized: Proper disposal of animations
๐ API Reference
SmartAppBar Class
Constructor Parameters
title(String?): Custom title overridevariant(SmartAppBarVariant?): Visual variant overrideactions(ListcenterTitle(bool): Center title alignmentbackgroundColor(Color?): Custom background colorforegroundColor(Color?): Custom text/icon colorenableAnimations(bool): Enable animationsisLoading(bool): Show loading indicatorshowBackButton(bool): Show navigation back buttononBackPressed(VoidCallback?): Custom back button handler
SmartAppBarVariant
standard: Standard Material 3 designglass: Glass morphism effecttransparent: Fully transparentbordered: Bordered appearanceelevated: Elevated with shadowlarge: Large title bar
SmartAppBarAction
notifications: Notification iconprofile: User profile iconedit: Edit/pencil iconshare: Share iconsettings: Settings gear iconsearch: Search magnifying glassmore: More options (3 dots)add: Plus/add iconfavorite: Heart/favorite iconbookmark: Bookmark icon
๐ค Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
๐ License
This project is licensed under the MIT License.
๐ฏ Example Project Structure
lib/
โโโ smart_appbar.dart # Main library file
โโโ src/
โ โโโ smart_appbar_core.dart # Core implementation
example/
โโโ main.dart # Example app
test/
โโโ smart_appbar_test.dart # Comprehensive tests
๐ฎ Future Enhancements
Built-in search functionalityMore animation presetsAdditional glass effectsContext menu supportGesture-based interactionsVoice command supportAI-powered auto-configuration
๐ Support
If you find this package helpful, please โญ star the repository!
For issues and questions:
Made with โค๏ธ for the Flutter community
Libraries
- demo_smart_appbar
- feature_showcase
- main
- smart_appbar
- SmartAppBar - Intelligent adaptive app bar for Flutter