Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dialog height too big #35

Closed
Hosam11 opened this issue May 5, 2021 · 6 comments
Closed

dialog height too big #35

Hosam11 opened this issue May 5, 2021 · 6 comments

Comments

@Hosam11
Copy link

Hosam11 commented May 5, 2021

how to remove this empty area from dialog ?

multiseclect dropdown

@Hosam11 Hosam11 closed this as completed May 5, 2021
@vcestra
Copy link

vcestra commented May 20, 2021

I have the same problem. How do you fix @Hosam11 ? Thanks

@Hosam11
Copy link
Author

Hosam11 commented May 20, 2021

@vcestra there is an height attribute you can give it double value

@vcestra
Copy link

vcestra commented May 21, 2021

Ok @Hosam11 . So you fix the height. Thanks

@Hosam11 Hosam11 reopened this Jun 7, 2021
@Hosam11
Copy link
Author

Hosam11 commented Jun 7, 2021

in version 3.1.7 the dialog height is fit to content of element inside the dropdown dialog and the below code work fine
MultiSelectDialog.dart in build method inside alert dialog the content

  content: Container(
        height: widget.height,
        child: SingleChildScrollView(
          child: widget.listType == null ||
                  widget.listType == MultiSelectListType.LIST
              ? ListTileTheme(
                  contentPadding: EdgeInsets.fromLTRB(14.0, 0.0, 24.0, 0.0),
                  child: ListBody(
                    children: _items.map(_buildListItem).toList(),
                  ),
                )
              : Wrap(
                  children: _items.map(_buildChipItem).toList(),
                ),
        ),
      ),

the new code

  content: Container(
        height: widget.height,
        child: SingleChildScrollView(
          child: widget.listType == null ||
                  widget.listType == MultiSelectListType.LIST
              ? ListTileTheme(
                  contentPadding: EdgeInsets.fromLTRB(14.0, 0.0, 24.0, 0.0),
                  child: ListBody(
                    children: _items.map(_buildListItem).toList(),
                  ),
                )
              : Wrap(
                  children: _items.map(_buildChipItem).toList(),
                ),
        ),
      )

here's I fix it use with v 4.0.0, wrap the Container with Column then give it MainAxisSize.min, then make ListView shrinkWrap: true

  content: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Container(
            height: widget.height,
            width: MediaQuery.of(context).size.width * 0.72,
            child: widget.listType == null ||
                    widget.listType == MultiSelectListType.LIST
                ? ListView.builder(
                    shrinkWrap: true,
                    itemCount: _items.length,
                    itemBuilder: (context, index) {
                      return _buildListItem(_items[index]);
                    },
                  )
                : SingleChildScrollView(
                    child: Wrap(
                      children: _items.map(_buildChipItem).toList(),
                    ),
                  ),
          ),
        ],
      )

@Hosam11 Hosam11 closed this as completed Jun 7, 2021
@NRMrYang
Copy link

NRMrYang commented Aug 4, 2022

@Hosam11 Hi, I use 4.1.2 ,and find content still uses Container instead of Column , should i alert source code?

@NRMrYang
Copy link

NRMrYang commented Aug 4, 2022

I have tried wrap the Container with Column then give it MainAxisSize.min, then make ListView shrinkWrap: true. If height is null, there is errors.I believe following steps will helps.

  1. wrap the Container with ConstrainedBox
  2. set minHeight: 0
  3. make ListView shrinkWrap: true
      content: ConstrainedBox(
        constraints: BoxConstraints(
          minHeight: 0,
        ),
        child: Container(
          height: widget.height,
          width: widget.width ?? MediaQuery.of(context).size.width * 0.73,
          child: widget.listType == null ||
              widget.listType == MultiSelectListType.LIST
              ? ListView.builder(
            itemCount: _items.length,
            shrinkWrap: true,
            itemBuilder: (context, index) {
              return _buildListItem(_items[index]);
            },
          )
              : SingleChildScrollView(
            child: Wrap(
              children: _items.map(_buildChipItem).toList(),
            ),
          ),
        ),
      ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants