generateBottomNavBar static method

String generateBottomNavBar()

Implementation

static String generateBottomNavBar() {
  return '''
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class CustomBottomNavBar extends StatelessWidget {
final int currentIndex;
final List<NavItem> items;

const CustomBottomNavBar({
  Key? key,
  required this.currentIndex,
  required this.items,
}) : super(key: key);

@override
Widget build(BuildContext context) {
  final theme = Theme.of(context);

  return Container(
    decoration: BoxDecoration(
      boxShadow: [
        BoxShadow(
          color: Colors.black.withOpacity(0.05),
          blurRadius: 10,
          offset: const Offset(0, -2),
        ),
      ],
    ),
    child: NavigationBar(
      selectedIndex: currentIndex,
      onDestinationSelected: (index) {
        if (index < items.length) {
          context.go(items[index].route);
        }
      },
      elevation: 0,
      backgroundColor: theme.scaffoldBackgroundColor,
      indicatorColor: theme.colorScheme.primary.withOpacity(0.15),
      labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
      height: 70,
      destinations: items.map((item) {
        return NavigationDestination(
          icon: Icon(item.icon),
          selectedIcon: Icon(item.selectedIcon),
          label: item.label,
        );
      }).toList(),
    ),
  );
}
}

class NavItem {
final String label;
final IconData icon;
final IconData selectedIcon;
final String route;

const NavItem({
  required this.label,
  required this.icon,
  required this.selectedIcon,
  required this.route,
});
}
''';
}