0

I am trying to save json object data locally when user closed the browser the data should not clear in flutter web. I try hive to store data locally but when browser closed the hive DB clear. I am using hive: ^2.0.4 plugin. There is any solution for that?
my function to save data using hive.

  Future addTransaction(
  {String userName,
  int userId,
  String userToken,
  String userFullName,
  String userProfileImage,
  String userFirstName,
  String userLastName}) async {
 try {
  final transaction = MultiAccount()
    ..userId = userId
    ..userName = userName
    ..userFirstName = userFirstName
    ..userLastName = userLastName
    ..userFullName = userFullName
    ..userToken = userToken
    ..userProfileImage = userProfileImage;

  final box = Boxes.getTransactions();
  final transactions = box.values.toList().cast<MultiAccount>();
  bool res = checkDataExist(transactions, userId);
  if (res == false) {
    box.add(transaction);
  }
} on Exception catch (e) {
  // TODO
  print("add error hive ... $e");
}
}
leftjoin
  • 36,950
  • 8
  • 57
  • 116
wahab sohail
  • 161
  • 1
  • 12

0 Answers0