buildDrawerOption method

Widget buildDrawerOption({
  1. required BuildContext context,
  2. required String text,
  3. required dynamic navigateTo(),
  4. TextStyle? textStyle,
  5. Widget? icon,
})

Builds a single drawer option with text and optional icon.

The option is rendered as a ListTile that closes the drawer and executes the navigation callback when tapped.

Implementation

Widget buildDrawerOption({
  required BuildContext context,
  required String text,
  required Function() navigateTo,
  TextStyle? textStyle,
  Widget? icon,
}) {
  return ListTile(
    leading: icon,
    title: Text(
      text,
      style: textStyle ??
          Theme.of(context).textTheme.bodyMedium!.copyWith(
                fontWeight: FontWeight.w500,
              ),
    ),
    onTap: () {
      Navigator.pop(context);
      navigateTo();
    },
  );
}