openlang

Can a shared showModalBottomSheet function serve several different pages in a flutter app?

I'd like Bottom Sheet in its own separate function, but haven't found how to arrange that. All the examples put Bottom Sheet inside a function, yet could I define one shared Bottom Sheet function and call it again from other places?

The conversation continues 2

Follow the reasoning
  1. Permalink

    Yes. Define a shared showModalBottomSheet function, with a child parameter carrying the view you want

    ///
    /// Open the shared modal sheet
    ///
    Future<R?> openSharedModal<R>({
        required BuildContext pageContext,
        required Widget content,
        bool? scrollControlled,
        ShapeBorder? borderShape,
        bool dismissible = true,
    }) {
        return showModalBottomSheet<R>(
            isDismissible: dismissible,
            context: pageContext,
            elevation: SheetSettings.elevation,
            barrierColor: SheetPalette.barrier,
            isScrollControlled: scrollControlled ?? true,
            enableDrag: true,
            backgroundColor: SheetPalette.modal.ofContext(_pageContext),
            shape: borderShape ?? SheetSettings.borderShape,
            builder: (BuildContext sheetContext) {
                return content;
            },
        );
    }

Other sides of the same question

  1. Making the sender appear as a label instead of an email address using Java Mail

    Im sending messages through the Java Mail API. On arrival, the inbox displays the address that sent the message. Id like some…

    Replies 2Latest activity java
  2. Dynamics CRM access from TypeScript

    Because my CRM code runs in a webresource, I have to write to retrieve the entity's data. Regrettably, that expression fails…

    Replies 2Latest activity typescript
  3. What date formatting does a Gleam HTTP response header need?

    I want to send a Date header. The required format looks like this: This is my current attempt:

    Replies 3Latest activity gleam