0

I have spent hours googling something that should be incredibly simple, but have found nothing to this sort on the internet. Effectively, I want to make a dropdown, so that when a button is clicked, I have a menu dropdown. However, I do not wish to have this dropdown be a list of items. I want the dropdown to be able to take in a child widget, similar to the showDialog function, and I can pass what I wish to the child widget.

Eg., I wish to merge dropdown's positioning with dialog ability to not only render an opinionated list.

Does anyone have any clue how to accomplish this?

3 Answers 3

2

You can use flutter_portal. I used this package to build many types of dropdowns. enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

issue with this is for switching between web and mobile the library doesn't really support the different views
0

Another way I found to do this is to use the showGeneralDialog function and customize the position.

Comments

0

What you could do is to copy the implementation of PopupMenuDivider:

class MyEntry extends PopupMenuEntry<Never> {
  const MyEntry();
  
  @override
  double get height => kMinInteractiveDimension;

  @override
  bool represents(void value) => false;

  @override
  State<MyEntry> createState() => _MyEntryState();
}

class _MyEntryState extends State<MyEntry> {
  @override
  Widget build(BuildContext context) {
    return MyWidget();
  }

And then you can use it in a PopupMenuButton:

class MyButton extends StatelessWidget {
  const MyButton();
  
  @override
  Widget build(BuildContext context) {
    return PopupMenuButton(
      itemBuilder: (context) {
        return [
          const MyEntry();
        ];
      },
      onSeleted: (_) {},
      child: MyChild(),
    );
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.