How To Store List in Hive? - Flutter

Viewed 45

I am building an application for experience. I am trying to store list in hive. So, can anyone explain how can I store list in hive?

In below list, all data are stored. I want to store these data in hive through all category list.

List<CategoryModel> allcategorylist =[]
1 Answers

Have you gone through the documentation?

Here is an example from the documentation.

import 'package:hive/hive.dart';

void main() async {
  var box = await Hive.openBox('someBox');

  var initialList = ['a', 'b', 'c'];
  box.put('myList', initialList);

  var myList = box.get('myList');
  myList[0] = 'd';

  print(initialList[0]); // d
}
Related