Getting ‘Horizontal viewport was given unbounded height.’ with TabBarView in flutter

The error description is clear, the TabBarView doesn’t have a bounded height. the parent widget also doesn’t have a bounded height. So, the Expanded widget will not solve this issue.

EDIT: below solutions are for above question(with columns).In general cases, use a ListView with shrinkWrap: true.(Or any other widgets with shrinkWrap) As @Konstantin Kozirev mentioned correctly, the shrinkWrap causes some performance issues. look for a better updated solution.

There are some options:

1st Solution:

Wrap the parent widget(Column) with a limited height widget like SizedBox or AspectRatio. Then use the Expanded widget like this:

Expanded(
  child: TabBarView(...),
)

2nd Solution:

Use a bounded widget like SizedBox or AspectRatio on the TabBarView itself:

SizedBox(
  height: 300.0,
  child: TabBarView(...),
)

Note Your can also calcuate the height dynamicly if the height is not static.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)