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

Just want to make the modal width bigger. #339

Open
ozayr opened this issue Nov 6, 2024 · 1 comment
Open

Just want to make the modal width bigger. #339

ozayr opened this issue Nov 6, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@ozayr
Copy link

ozayr commented Nov 6, 2024

is there a way or property to just make the modal width bigger without extending or overriding as it was before with maxdialogwidth ?

@ulusoyca
Copy link
Collaborator

ulusoyca commented Nov 10, 2024

Hi @ozayr,

Yes it is possible. You just need to create your own modal type. Here you need to override only layoutModal.

class _MyModalDialog extends WoltModalType {
  @override
  BoxConstraints layoutModal(Size availableSize) {
    final availableWidth = availableSize.width;
    double width = availableWidth > 523.0 ? 312.0 : availableWidth - padding.end;
    return BoxConstraints(
      minWidth: width,
      maxWidth: width,
      minHeight: 0,
      maxHeight: availableSize.height * 0.6,
    );
  }
}

Then, when you are calling your modal:

WoltModalSheet.show(
  context: context,
  modalTypeBuilder: (BuildContext context) {
    final width = MediaQuery.sizeOf(context).width;
    if (width < 523) {
      return WoltModalType.bottomSheet();
    } else {
      return _MyModalDialog();
    },
    ...
},

Please let me know if this works!

@ulusoyca ulusoyca self-assigned this Nov 10, 2024
@ulusoyca ulusoyca added the question Further information is requested label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants