woltapp / wolt_modal_sheet

This package provides a responsive modal with multiple pages, motion animation for page transitions, and scrollable content within each page.
MIT License
511 stars 64 forks source link

Just want to make the modal width bigger. #339

Closed ozayr closed 3 days ago

ozayr commented 2 weeks ago

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

ulusoyca commented 1 week ago

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 commented 3 days ago

@ozayr Please re-open this issue if this does not answer your request.