top of page

[Flutter/dart] Make sure that Stack does not break part of the widget


phenomenon


You can use the Stack () widget in flutter to stack another widget on top of one. However, if the upper widget protrudes from the lower widget, the protruding part will be interrupted.


Stack(
  children: [
    CircleAvatar(
      child: Icon(Icons.person),
    ),
    Positioned(
      top: -8,
      left: 20,
      child:
        Icon(
          Icons.brightness_1,
          color: Colors.red,
        )
    )
  ],
)
The upper right is cut off


Solution


Set the overflow property of Stack to Overflow.visible.

With this, the protruding part will be displayed without interruption.


Stack(
  overflow: Overflow.visible,  //←this!
  children: [
    CircleAvatar(
      child: Icon(Icons.person),
    ),
    Positioned(
      top: -8,
      left: 20,
      child:
        Icon(
          Icons.brightness_1,
          color: Colors.red,
        )
    )
  ],
)

The upper right was also displayed


Recent Posts

See All

Comentarios


category

Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page