Skip to content

Instantly share code, notes, and snippets.

@2shrestha22
Last active March 25, 2021 10:11
Show Gist options
  • Save 2shrestha22/42cf47e24c329ed24002ed1d5f6c14ed to your computer and use it in GitHub Desktop.
Save 2shrestha22/42cf47e24c329ed24002ed1d5f6c14ed to your computer and use it in GitHub Desktop.
//where _kAdIndex is an int and after each -kAdIndex in the listView Ad is displayed
ListView.builder(
controller: _scrollController,
cacheExtent: 20,
itemCount: data.layoutList.length +
(data.layoutList.length ~/ _kAdIndex),
itemBuilder: (BuildContext context, int index) {
if (index != 0 && (index + 1) % (_kAdIndex + 1) == 0) {
print(index);
print(index ~/ _kAdIndex);
return MyAdWidget();
} else {
return LayoutListItem(
layout: data
.layoutList[index - (index ~/ (_kAdIndex + 1))],
);
}
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment