Widget build(context) {
try{
if (isFirst == true) {
fetchImage();
fetchCategories(context);
isFirst = false;
}
}catch(Excepti
I assume you getting data from fetch ApI method, If you are getting data in fetchApI metod. then you should follow this
fetchApI and is asynchronous method so it takes time to get data from json and in the begging fetchApI is empty, so it gives error of range.
you can make fetchApI method asynchronous using await and async* and while calling that method use .then method and then access values.
fetchApI().then((){ // access fetchApI over here });