I want to show the list items in mixed layout, where the first two items will be in full-width Card layout and the next two items will be in Grid layout.
so far I have tried to divide the items by separating even, add numbers, but am stuck at the next condition, am not sure whether it's a good approach to achieve this.
any suggestion would be appreciated.
ListView.builder(
key: PageStorageKey("topNewsListKey"),
itemCount: _newsList.length + (_hasMore ? 1 : 0),
itemBuilder: (context, index) {
if(index % 2 == 0) {
print('even numbers $index');
if( ) { // condition to divide index 0,4,8...
return fullWidthCardLayout();
} else {
return gridLayout();
}
} else {
print('odd numbers $index');
if() { // condition to divide index 1,5,9...
return fullWidthCardLayout();
} else {
return gridLayout();
}
}
});
question from:
https://stackoverflow.com/questions/65949171/flutter-list-items-in-mixed-layout-for-each-two-items 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…