8

I got this when I was using Hive Database in Flutter. Find out answer below

padaleiana
  • 955
  • 1
  • 14
  • 23
vivek yadav
  • 1,367
  • 2
  • 12
  • 16

4 Answers4

6

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.

vivek patel
  • 95
  • 1
  • 15
6

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.

Yash Zade
  • 163
  • 1
  • 4
0

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.

vivek yadav
  • 1,367
  • 2
  • 12
  • 16
0

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

Amo Oniani
  • 15
  • 3