I have a dialog with a button and I want to add a horizontal scroll next to the button, so this way the button is fixed in the left and the scroll is in the right. I tried using a Row but I got the following error:
The following assertion was thrown during performResize(): Horizontal viewport was given unbounded width. . . . The following assertion was thrown during performLayout(): RenderBox was not laid out: RenderViewport#48cb5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1982 pos 12: 'hasSize' . . .
The specific code I used for this is the following:
SizedBox(
height: 80,
child: Row(
children: <Widget>[
AddUsersButton(newTaskCubit: newTaskCubit),
SizedBox(
height: 80,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
],
),
)
],
),
),
Give SizeBox() width also and use shrikWrap with your Listview .As the scroll is Horizontal its asking for you a fixed widht.
You can use shrinkWrap: true, on ListView
SizedBox(
height: 80,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[....],
),
You can check more about What does the shrinkWrap property do in Flutter?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With