I have a horizontal ListView.builder
. The image attached demonstrates my UI.
The listView
(red). itemBuilder
button widgets (blue); The margin (green).
When the list is scrolled to the edge, without a margin, my button will be visibly against the edge of the screen.
If I add a margin
or padding
via a Container
or the ListView
, it moves my UI in as expected.
However, when I scroll my list, items in the list are now clipped by this margin and do not scroll to the edge of the screen, but the margin boundary.
How can I have an inset that doesn't clip my list when scrolling?
The solution to resolve this overflow error is to make your entire widget or in our case the Column scrollable. We can do that by wrapping our Column inside a SingleChildScrollView.
Clip clipBehavior. Controls how the contents of the dialog are clipped (or not) to the given shape. See the enum Clip for details of all possible options and their common use cases. Defaults to Clip. none, and must not be null.
The Text may overflow from the widgets like containers, cards, etc. The Text Widget has a property overflow to handle the overflow text in android, IOS, WEB, desktop applications. Overflow property has multiple parameters like clip, ellipsis, fade, visible, etc.
ListView
possess a padding
property for that purpose.
The following code will offset the first element by 8. But that padding won't clip the list content, as opposed to wrapping ListView
inside a Padding
.
ListView.builder(
padding: EdgeInsets.only(top: 8.0),
itemBuilder: (context, index) {
return Container(
height: 42.0,
color: index % 2 == 0 ? Colors.red : Colors.blue,
);
},
),
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