dart – How to convert the whole Hive Box to Map in flutter?


I have a Flutter Hive called cartModel(); with typeadaper as such

@HiveType(typeId: 0)
class CartModel extends HiveObject {
  // for the product title
  late final String title;
  // for checking the store id
  late final String uid;
  // fot the product image
  late final String image;
  // for the discounted price
  late final double price;
  // for the original price
  late final double originalPrice;
  // for the quantity.
  late final int quantity;

    required this.image,
    required this.originalPrice,
    required this.price,
    required this.quantity,
    required this.uid,
    required this.title,

and the specific data is saved as CartModed<>.


I want to convert the whole cartModel to a dart Map{} object and save it to the database (firebase firestore).

Problem I am facing:

I have a cartModel<>(imageUrl, title, price, quantity) I can access data of each model as such CartModel.image but the limitation is I can access specific data of a single index and when I try to access the whole box (hive box) it just shows Instance of CartModel<>.

What I’ve tried so far:

Hive.box('cartModel').value;  but it returns the above mentioned problem.

Full Code:

incase if you would be intrested to view the full code I have attached a github link bellow:

github link to full code.