GithubHelp home page GithubHelp logo

Comments (5)

AhmedLSayed9 avatar AhmedLSayed9 commented on June 4, 2024

I've tested it and buttonDecoration is applied on the button when using Android's back button.
Could you please share a sample example that produce this issue?

from dropdown_button2.

EskAere avatar EskAere commented on June 4, 2024

Hi, thanks you for your quick response.

Here is a simplified version of my Dropdown Widget :

class DropdownWidget extends StatefulWidget {
  final List<String> values;
  final String? value;
  final Function(String?)? onChanged;

  const DropdownWidget({
    Key? key,
    required this.values,
    required this.value,
    required this.onChanged,
  }) : super(key: key);

  @override
  State<DropdownWidget> createState() => _DropdownWidgetState();
}

class _DropdownWidgetState extends State<DropdownWidget> {
  bool _isDropdownOpen = false;

  @override
  Widget build(BuildContext context) {
    return DropdownButtonHideUnderline(
      child: DropdownButton2(
        isExpanded: true,
        value: widget.value,
        onChanged: widget.onChanged,
        onMenuStateChange: (isOpen) {
          setState(() {
            _isDropdownOpen = isOpen;
          });
        },

        //Items
        itemPadding: EdgeInsets.zero,
        items: widget.values.map((String type) {
          return DropdownMenuItem<String>(
            value: type,
            child: Text(type),
          );
        }).toList(),

        //Button
        buttonHeight: 50.0,
        buttonPadding: const EdgeInsets.symmetric(horizontal: 14),
        buttonDecoration: BoxDecoration(
          borderRadius: _isDropdownOpen
              ? BorderRadius.only(
                  topLeft: Radius.circular(10),
                  topRight: Radius.circular(10),
                )
              : BorderRadius.circular(10),
          color: AppColors.white,
        ),

        //Dropdown
        dropdownDecoration: BoxDecoration(
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10),
            bottomRight: Radius.circular(10),
          ),
          color: AppColors.white,
        ),
        dropdownPadding: EdgeInsets.zero,
        dropdownElevation: 0,
        dropdownMaxHeight: 250,
        scrollbarAlwaysShow: true,
      ),
    );
  }
}

To reproduce :
1 - Open dropdown, close by tapping anywhere outside the dropdown. All good.
2 - Open dropdown, close using Android back button. The button ends up with the dropdownDecoration.

The issue probably comes from the usage of onMenuStateChanged.
Does onMenuStateChanged have the same behaviour when dropdown is closed via back button/other ways ?

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on June 4, 2024
Screen.Recording.2022-07-18.at.6.04.53.PM.mov

I've tried your sample code and couldn't reproduce the issue.
onMenuStateChange triggers when the dropdown menu route get removed whatever the way.

from dropdown_button2.

EskAere avatar EskAere commented on June 4, 2024

Indeed !
You made me try on an emulator and the issue is gone.

However, even on an empty project (just like you), the issue persists on my physical Android device.
I'll leave it as is for now and investigate later, but I guess the issue is not related to your package.

Thank you for your time <3
I suppose the issue can be closed for now ? I'll reopen if needed

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on June 4, 2024

I've never noticed this issue on my old physical Android device (using iPhone now). so, It might be related to your device.
You should try to test it on another device that might help finding if the issue related to some device?

Alright! I'll close this for now. Feel free to re-open if needed.

from dropdown_button2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.