huextrat / menu_button

Flutter plugin to display a popup menu button widget with handsome design and easy to use.
https://pub.dev/packages/menu_button
MIT License
65 stars 23 forks source link

Ripple effect not showing on items when decoration.color is set #14

Closed WieFel closed 3 years ago

WieFel commented 3 years ago

Is your feature request related to a problem? Please describe. When I set the MenuButton's decoration to decoration: BoxDecoration(color: Colors.white) the ripple effect when clicking an items is not showing. This happens because of this well-known fact. The color of the decoration covers the underlying InkWell. When setting no color on the decoration, the items are translucent but the ripple effect does show. Here is a screenshot of how that looks:

Simulator Screen Shot - iPhone 12 Pro Max - 2021-02-16 at 10 47 58

Describe the solution you'd like A simple color property for the drop-down items that is applied to the parent of the InkWell could solve the problem. E.g. adding a property itemBackground to MenuButton, then pass it from MenuButton to _MenuItem<T> and then within _MenuItem<T> do:

@override
  Widget build(BuildContext context) {
    return Material(
        color: itemBackground,
        child: InkWell(
            onTap: () => Navigator.of(context).pop<T>(value), child: child
        ),
    );
  }

Describe alternatives you've considered As described above, omitting decoration color, which didn't help.

huextrat commented 3 years ago

Hey @WieFel ! Thank you for your proposal.

Can you please check the PR #16 and confirm to me that it meets your expectations ;)

WieFel commented 3 years ago

@huextrat exactly! Thank you very much! ;)

huextrat commented 3 years ago

I will try to deliver a 1.3.0 with this change during the day ;)