Flutter MouseRegion is not working when the child is a Chip Widget

246

Instead of MouseRegion and GestureDetector on a Chip, you want to use ActionChip instead.

    ActionChip(
        onPressed() {/* use onPressed even if it would be empty */}
        backgroundColor: kLightPrimary,
        avatar: const Icon(
           Feather.phone_call,
           size: 18.0,
           color: kPrimaryColor,
        ),
        label: Text(
          "Test num",
          style: GoogleFonts.poppins(
              fontWeight: FontWeight.w500, color: kPrimaryColor),
          textAlign: TextAlign.end,
        ),
        padding: const EdgeInsets.all(kDefaultPadding),
      )
Share:
246
Proov_14
Author by

Proov_14

Updated on January 02, 2023

Comments

  • Proov_14
    Proov_14 over 1 year

    The mouse cursor in my flutter web program is not changing to a click cursor on hover when the child is a Chip widget. I changed the Chip to a Text and a Container widget and the mouse cursor changes without any issues.

    Below is the code of the MouseRegion.

    return MouseRegion(
      cursor: SystemMouseCursors.click,
      child: Container(
        width: 200,
        alignment: Alignment.centerRight,
        child: GestureDetector(
          onTap: () {},
          child: Chip(
            backgroundColor: kLightPrimary,
            avatar: const Icon(
               Feather.phone_call,
               size: 18.0,
               color: kPrimaryColor,
            ),
            label: Text(
              "Test num",
              style: GoogleFonts.poppins(
                  fontWeight: FontWeight.w500, color: kPrimaryColor),
              textAlign: TextAlign.end,
            ),
            padding: const EdgeInsets.all(kDefaultPadding),
          ),
        ),
      ),
    ),
    
  • Proov_14
    Proov_14 over 2 years
    I have tried that, it's not working. the mouse cursor remains as default cursor on hover.
  • Proov_14
    Proov_14 over 2 years
    It works perfectly man! :) Thank youu