Skip to content

Alignment top center pulls dialogs up #27

@SpencerLindemuth

Description

@SpencerLindemuth

I'm using a very narrow testing scope so this may have some severe unintended consequences, but in ResponsiveWrapper, is there a reason the Stack that wraps the resized widget aligns top center and not center? If you use the showDialog method with a SimpleDialog child, it floats to the top when used with a ResponsiveWrapper instead of the native center float. Changing the stack alignment fixes the issue and I don't see any other consequences but again I have a pretty narrow scope.

Here's the code in question in responsive_wrapper.dart starting on line 457

  @override
  Widget build(BuildContext context) {
    return (screenWidth ==
            0) // Initialization check. Window measurements not available until postFrameCallback.
        ? (widget.backgroundColor ??
            Container(
                color: Color(
                    0xFFFFFFFF))) // First frame empty background color or default white.
        : InheritedResponsiveWrapper(
            data: ResponsiveWrapperData.fromResponsiveWrapper(this),
            child: Stack(
             ***alignment: Alignment.topCenter,***
              children: [
                widget.background ?? SizedBox.shrink(),
                MediaQuery(
                  data: calculateMediaQueryData(),
                  child: SizedBox(
                    width: screenWidth,
                    child: FittedBox(
                      fit: BoxFit.fitWidth,
                      alignment: Alignment.topCenter,
                      child: Container(
                        width: scaledWidth,
                        height: (widget.shrinkWrap == true &&
                                widget.mediaQueryData == null)
                            ? null
                            : scaledHeight,
                        // Shrink wrap height if no MediaQueryData is passed.
                        alignment: Alignment.center,
                        child: widget.child,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          );
  }

Changing to Alignment.center works like expected. Let me know if you have any feedback on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions