简体   繁体   中英

Flutter - How to create fluid / dynamic container that follows it's parent height?

I want to have a line that has 100% parent height, the line should has a fluid height following it's parent's height. the parent's height would be dynamic because every content has it's own height. Just like in Path app.

This is my app, currently I'm setting the height as a constant, how to make it dynamic following it's parent's height? :

Container(
  width: 1,
  color: Colors. redAccent,
  height: 300, // <-- this height
)

截图

try to use the Expanded Widget which uses the available space. you just have to definewhat is the available space here

Expanded(
          child: Container(
            color: Colors.amber,
            width: 100,
          ),
        ),

here, if you dont put something on top of the expanded, it will take all the screen and if not on the bottom, it will reach the bottom of the screen.

it takes the whole free space.

I solved this by adding container and add border left:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM