I got this when I was using Hive Database in Flutter. Find out answer below
I got this when I was using Hive Database in Flutter. Find out answer below
I was getting the same error. when I was trying to add data into hive database using putAt(), but from documantion i found out that putAt() can only be used for the existing index. so switch putAt() instruction with add(). That solved the error.
I know the question is old, but I hope it could help someone.
problem for me was, I am accessing the empty list with index.
ex:
list=[ ] //this is empty list
list[0] // error, because I am accessing empty list.
So whenever you get this kind of Error!
Check if whatever you are saving in Hive Database is not null. I got this error while I was storing null object to database.
you should give and initializer for example if you want to give and array you should set a default value for example :
List<dynamic> _users = [];
this return error
but if you do this your problem will be solve :
List<dynamic> _users = [
{
"id":"",
"name:"",
"Phone:""
}
]
depends of your data that fields