I have been trying to add an button to the end of a listview builder. I tried to do what was suggested in this question: Flutter: How to add a button widget at the end of a ListView.builder that contains other type of widgets?. But if i do that i get: "RangeError (index): Invalid value: Not in inclusive range 0..49: 50
I tried looking at questions that also had this problem but i couldnt find an anwser that fixed it.
List<Anime> animeList = animeData.animeList;
print(animeList.length);
return ListView.builder(
padding: EdgeInsets.only(bottom: 30, top: 10),
itemBuilder: (context, index) {
Anime anime = animeList[index];
if (index == animeList.length) {
return ThinOutlineBtn(
primaryColor: themeWizard.getPrimaryColor(),
darkColor: themeWizard.getBackgroundColor(),
text: "More",
highlightedBorderColor: themeWizard.getPrimaryColor(),
ontap: () {
AnilistApi.followUpQuery(AnilistApi.animeQuery, animeData,
animeData.animePage.currentPage + 1);
},
);
}
return AnimeCard(
anime: anime,
darkMode: themeWizard.getCurrentMode(),
activeIcon: themeWizard.getPrimaryColor(),
background: themeWizard.getCardColor(),
btnHighlightColor: themeWizard.getBackgroundColor(),
textColor: themeWizard.getCardTextColor(),
inActiveIcon: themeWizard.getIconColor(),
);
},
itemCount: animeList.length + 1,
);