codeKiller
codeKiller

Reputation: 5739

Flutter OverlayEntry not taking width, height

I am trying to display an OverlayEntry below one of my Textfields.

It is working so far, the only problem is with the OverlayEntry itself, for some reason, whatever width and height I give to the child, the Overlay takes all available screen width, and all the way down to the bottom of the screen in height.

Here some code, where as a sample, im just trying to show a small red square of 100x100...not working:

OverlayEntry _getOverlay() {
    return OverlayEntry(
      builder: (context) => CompositedTransformFollower(
        link: _layerLink,
        showWhenUnlinked: false,
        offset: Offset(0, fieldHeight + 5),
        child: Container(
          width: 100,
          height: 100,
          color: Colors.red,
        ),
      ),
    );
  }

How do I manage the width and height of the OverlayEntry??

Upvotes: 0

Views: 3934

Answers (1)

Abhay Koradiya
Abhay Koradiya

Reputation: 2117

not checked, but might be worked.

use Positioned inside OverlayEntry. check below example.

return OverlayEntry(
      builder: (context) => Positioned(
        width: 100,
        height: 100,
        child:CompositedTransformFollower(
             link: this._layerLink,
             child: Container(
                 color: Colors.red,
             ),
        ),
      ),
    );

Upvotes: 9

Related Questions