Questions tagged [flutter-hive]

Use this tag when the question is related to the key-value database written in Dart, in combination with a project written in Flutter.

Summary

Hive is a key-value database written in pure Dart.

The data are arranged in boxes, which can also be encrypted for the storage of sensitive data. The box must be opened before use.

Useful Links

380 questions
26
votes
8 answers

Flutter : Could not find package "build_runner"

I work with Hive Packages, I implement Modularization in my project. first i create packages with name network with run command flutter create --template=package network, I reference this. This packages include models of my project. after that I…
Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89
20
votes
3 answers

combine freezed & hive

I'm searching for a solution to combine freezed and hive packages. For example like that: @freezed abstract class Person extends HiveObject with _$Person { @HiveType(typeId: 0) factory Person({@HiveField(0) String name, @HiveField(1) int age}) =…
DennisSzymanski
  • 578
  • 4
  • 11
16
votes
3 answers

How to save a List and retrieve using Hive?
I have a Wallpaper App and it uses Firestore to store the wallpapers. I want to use Hive to store a list of wallpapers from cloud firestore but how to save the List of Wallpapers and retrieve it later? When I try to save the list I get this…
djalmafreestyler
  • 1,703
  • 5
  • 21
  • 42
10
votes
3 answers

Flutter hivebox HiveError: Box has already been closed

I am using this function to make sure to open and close box appropriately but i am still getting HiveError: Box has already been closed. error static Future> openIt() async { var connectionBox = await Hive.openBox(hiveBox); if…
Bilal Rabbi
  • 1,602
  • 2
  • 18
  • 39
10
votes
6 answers

How to update specific field of hive object in flutter?

I am using hive as my NoSQL local database in my flutter app. Following is my Hive Class: import 'dart:convert'; import 'package:hive/hive.dart'; import 'package:lpa_exam/src/model/listofexams.dart'; import…
Gaurav Kumar
  • 1,111
  • 6
  • 25
  • 52
9
votes
5 answers

Error: "type 'UnspecifiedInvalidResult' is not a subtype of type 'LibraryElementResult' in type cast" in Flutter Hive

I run flutter packages pug run build_runner build, the normal command with which you would create a TypeAdapter in Flutter, I get the following error: type 'UnspecifiedInvalidResult' is not a subtype of type 'LibraryElementResult' in type cast It…
Boothosh81
  • 387
  • 1
  • 5
  • 24
8
votes
4 answers

RangeError (index): Index out of range: no indices are valid: 0

I got this when I was using Hive Database in Flutter. Find out answer below
vivek yadav
  • 1,367
  • 2
  • 12
  • 16
8
votes
4 answers

The box "contacts" is already open and of type Box when trying to access Hive database in flutter

I initialized box database in main as follow void main() async { WidgetsFlutterBinding.ensureInitialized(); final appDocumentDirectory = await path_provider.getApplicationDocumentsDirectory(); Hive.init(appDocumentDirectory.path); …
aboodrak
  • 873
  • 9
  • 15
7
votes
2 answers

Flutter Hive: TypeAdapter vs saving as json string?

I have learned that with hive database in flutter it is possible to store custom objects as json strings. And then there is the option to write a custom type adapter that stores the data in binary format. So, why it could be needed to spend more…
lxknvlk
  • 2,744
  • 1
  • 27
  • 32
7
votes
2 answers

Flutter dart export hive saved data to file to retrieve later

I am developing a barcode app and save the data to hive. What I need to know is there a way to export the saved hive database to a backup file and be able to retrieve it for instance if the app crashed or your phone is lost. This is for blind…
Hendrik
  • 135
  • 1
  • 10
7
votes
4 answers

HiveError: There is already a TypeAdapter

I'm currently implementing Hive in my FlutterApp. Unfortunately this error pops up all the time: HiveError: There is already a TypeAdapter for typeId 100. This is my object: @HiveType(typeId: 100) class ShopList{ @HiveField(0) String name; …
benicamera
  • 750
  • 1
  • 7
  • 24
7
votes
3 answers

How to delete all the boxes in Hive Flutter?

I am developing an application using Flutter; it will store some data locally, so I decided to use Hive package which was really amazing package to store data. So now I will store all the data locally when the user press the sync button. After that,…
Praveen Kumar U
  • 157
  • 1
  • 2
  • 6
6
votes
5 answers

Flutter Hive save custom object with list of custom objects gone after restarting app

I am using the Hive- Package in my project to store some data locally. That has been working fine so far, but now I am facing an issue: I have a Custom-Class which also has a field with another Custom-Class: part…
Chris
  • 1,828
  • 6
  • 40
  • 108
6
votes
9 answers

Flutter hive: cannot generate Adapter files

I have a model like so: import 'package:uuid/uuid.dart'; import 'package:hive/hive.dart'; part 'config_item.g.dart'; @HiveType() class ConfigItem { @HiveField(0) String _id; // this can be a uuid or a MongoDB ObjectID @HiveField(1) final…
ThommyB
  • 1,456
  • 16
  • 34
6
votes
7 answers

Flutter Hive - how to locate box files

This may be obvious, but can someone please tell me how I can locate my Hive Box file after initialising Hive in a Flutter application, using Android Studio? I have followed the documentation here - https://docs.hivedb.dev/#/README - and my basic…
mav91
  • 165
  • 2
  • 14
1
2 3
25 26