apptomate_custom_drawer 0.0.1 copy "apptomate_custom_drawer: ^0.0.1" to clipboard
apptomate_custom_drawer: ^0.0.1 copied to clipboard

An enhanced implementation of Flutter's Drawer with extensive customization options and a clean API.

example/lib/main.dart

import 'package:apptomate_custom_drawer/apptomate_custom_drawer.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const CustomDrawerWidget(),
    );
  }
}

class CustomDrawerWidget extends StatelessWidget {
  const CustomDrawerWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Custom Drawer')),
      drawer: CustomDrawer(
        title: 'Menu',
        backgroundColor: Colors.grey[100]!,
        width: 280.0,
        profileSection: Container(
          width: 300,
          height: 200,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const CircleAvatar(
                radius: 40,
                backgroundImage: NetworkImage(
                    'https://www.w3schools.com/w3images/avatar2.png'),
              ),
              const SizedBox(height: 8),
              const Text(
                'John Doe',
                style: TextStyle(
                    fontSize: 18,
                    color: Colors.white,
                    fontWeight: FontWeight.bold),
              ),
              const Text(
                'johndoe@example.com',
                style: TextStyle(fontSize: 14, color: Colors.white70),
              ),
            ],
          ),
        ),
        items: [
          DrawerItem(
            label: 'Home',
            icon: Icons.home,
            iconColor: Colors.blue,
            textColor: Colors.black,
            onTap: () => _showSnackBar(context, 'Home tapped'),
          ),
          DrawerItem(
            label: 'Profile',
            icon: Icons.person,
            iconColor: Colors.green,
            textColor: Colors.black,
            onTap: () => _showSnackBar(context, 'Profile tapped'),
          ),
          DrawerItem(
            label: 'Settings',
            icon: Icons.settings,
            iconColor: Colors.orange,
            textColor: Colors.black,
            onTap: () => _showSnackBar(context, 'Settings tapped'),
          ),
          DrawerItem(
            label: 'Logout',
            icon: Icons.exit_to_app,
            iconColor: Colors.red,
            textColor: Colors.black,
            onTap: () => _showSnackBar(context, 'Logged out'),
          ),
        ],
        footer: Text(
          'Version 1.0.0',
          style: TextStyle(color: Colors.grey[600], fontSize: 12),
        ),
        footerPadding: const EdgeInsets.all(16.0),
      ),
      body: const Center(child: Text('Swipe from left to open drawer')),
    );
  }

  void _showSnackBar(BuildContext context, String message) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text(message)),
    );
  }
}
0
likes
150
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

An enhanced implementation of Flutter's Drawer with extensive customization options and a clean API.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on apptomate_custom_drawer