Reputation: 1681
I'd like to render a PageView
but instead of the currentIndex
for each page being numbered sequentially IE: 1,2,3,4,5,6,7,8,9 I'd like to reverse the numbering IE: 9,8,7,6,5,4,3,2,1.
Anybody know a way to do this??
PageView.builder(
itemCount: message.length,
itemBuilder: (context, int currentIndex) {
return createViewItem(message[currentIndex], context, );
},
);
}
Upvotes: 1
Views: 379
Reputation: 2529
try this:
PageView.builder(
itemCount: message.length,
itemBuilder: (context, int currentIndex) {
return createViewItem(message[(message.length+1)-currentIndex], context, );
},
);
}
if starting from the 0
index, You must decrease 1
like this:
return createViewItem(message[(message.length-1)-currentIndex], context);
Upvotes: 2