adaptive_scaffold_plus 1.1.1
adaptive_scaffold_plus: ^1.1.1 copied to clipboard
A production-ready replacement for flutter_adaptive_scaffold. Adapts navigation (BottomNavigationBar, NavigationRail, Drawer) per Material 3 guidelines.
import 'package:flutter/material.dart';
import 'package:adaptive_scaffold_plus/adaptive_scaffold_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'adaptive_scaffold_plus',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const AdaptiveDemo(),
);
}
}
class AdaptiveDemo extends StatelessWidget {
const AdaptiveDemo({super.key});
static const List<AdaptiveDestination> _destinations = [
AdaptiveDestination(
icon: Icons.home_outlined,
selectedIcon: Icons.home,
label: 'Home',
),
AdaptiveDestination(
icon: Icons.search_outlined,
selectedIcon: Icons.search,
label: 'Search',
),
AdaptiveDestination(
icon: Icons.favorite_outline,
selectedIcon: Icons.favorite,
label: 'Favourites',
),
AdaptiveDestination(
icon: Icons.person_outline,
selectedIcon: Icons.person,
label: 'Profile',
),
];
static const List<_PageContent> _pages = [
_PageContent(title: 'Home', color: Color(0xFFE8F5E9), icon: Icons.home),
_PageContent(title: 'Search', color: Color(0xFFE3F2FD), icon: Icons.search),
_PageContent(
title: 'Favourites',
color: Color(0xFFFCE4EC),
icon: Icons.favorite),
_PageContent(
title: 'Profile', color: Color(0xFFF3E5F5), icon: Icons.person),
];
@override
Widget build(BuildContext context) {
return AdaptiveScaffoldPlus(
destinations: _destinations,
appBar: AppBar(
title: const Text('adaptive_scaffold_plus'),
centerTitle: false,
),
navigationHeader: const Padding(
padding: EdgeInsets.all(16),
child: Text(
'MY APP',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
),
// Frosted-glass, pill-shaped bar that floats above the body content
// instead of the standard docked, opaque NavigationBar.
navigationStyle: AdaptiveNavigationStyle.floating,
body: (index) => _pages[index].build(context),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
);
}
}
class _PageContent {
final String title;
final Color color;
final IconData icon;
const _PageContent({
required this.title,
required this.color,
required this.icon,
});
Widget build(BuildContext context) {
return Container(
color: color,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 80, color: Colors.black38),
const SizedBox(height: 16),
Text(
title,
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: 8),
Text(
'Resize the window to see the layout change!',
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
);
}
}