DEV Community

Cover image for Flutter Drawer In easy way
Nitish Kumar
Nitish Kumar

Posted on

Flutter Drawer In easy way

Flutter Drawer In easy way

DrawerList.dart

class DrawerList extends StatelessWidget {
  final String icon, title;
  final VoidCallback onTap;
  const DrawerList(
      {super.key,
      required this.icon,
      required this.title,
      required this.onTap});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      hoverColor: lightGreen,
      onTap: onTap,
      horizontalTitleGap: 0.0,
      leading: SvgPicture.asset(
        icon,
        width: 25,
        color: lableColor,
      ),
      title: Text(title),
      // iconColor: deepGreen,
      textColor: lableColor,
    );
  }
}
Enter fullscreen mode Exit fullscreen mode

Drawer.dart

Drawer(
      child: Container(
        color: fontColor,
        child: Column(children: [
          SizedBox(height: 30),
          Container(
            margin: EdgeInsets.all(10),
            padding: EdgeInsets.all(10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  padding: EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      color: whiteColor,
                      borderRadius: BorderRadius.circular(5)),
                  child: Center(
                    child: SvgPicture.asset(
                      "assets/icons/icon.svg",
                      color: fontColor,
                    ),
                  ),
                ),
                SizedBox(width: 10),
                Text(
                  "FALTU DUKAN",
                  style: Theme.of(context)
                      .textTheme
                      .titleLarge
                      ?.copyWith(color: whiteColor),
                ),
              ],
            ),
          ),
          DrawerList(
            icon: "assets/icons/icon.svg",
            title: "HOME",
            onTap: () {
              print("HomePage");
            },
          ),
          DrawerList(
            icon: "assets/icons/transaction.svg",
            title: "SALE / PURCHASE",
            onTap: () {
              print("Sale pruchase");
            },
          ),
          DrawerList(
            icon: "assets/icons/party.svg",
            title: "PARTY",
            onTap: () {
              print("Party");
            },
          ),
          DrawerList(
            icon: "assets/icons/item.svg",
            title: "ITEM",
            onTap: () {
              print("Item Page");
            },
          ),
          DrawerList(
            icon: "assets/icons/setting.svg",
            title: "SETTINGS",
            onTap: () {
              print("Setting Page");
            },
          ),
        ]),
      ),
    );
Enter fullscreen mode Exit fullscreen mode

For More information visit codesikhe.com

Top comments (0)