After watching lots of video about hive I can say that this is one of the best and thank you Johannes. Only thing that you can add is how to use asset hive database which is quite rare scenario.
@Johannes Milke how do you paste your code very fast in this way example(1) -> example(2) -> example(3) -> example(4) -> example(5) -> example(6) just go in this time 3:35 and you will understand me.
Thank You s vijay kumar! Follow this link: medium.com/flutter-community/storing-local-data-with-hive-and-provider-in-flutter-a49b6bdea75a I hope you will get your answer 🙂
Good question, Helvecio Borges! 🙂 There are multiple scenarios - In case internet is not connected and still you wanna show some data - Loading from local is way faster then loading from cloud so in case there is some repetition of loading data you can store it locally - In case you just want to make a application with no need of cloud other than storing data. You can use local DB - and many more
I am always your video follower everyday I want to ask something about this When user register some data on the text field and add the amount then finally display on the list My question is that when user enter the again new data on textfield then previous one data already store on that textbox Is there any solution to remove that previous data store on while user enter second data item I have use dispose also not working yet
Thank You Sampelmind81! Follow this link: stackoverflow.com/questions/64020930/can-hive-in-flutter-store-bigdatasome-gb-files I hope you will get your answer 🙂
Thank You theycallmephenomenal! Follow this link: medium.com/flutter-community/storing-local-data-with-hive-and-provider-in-flutter-a49b6bdea75a I hope you will get your answer 🙂
hi johannes at the end you said that for more complex database operations sqlfite is best over hive can you please explain me how ,please elaborate ,please give a scenario
Hi Johannes, thanks for the tutorial. When I run "flutter packages pub run build_runner build" I get that it succeeded with 0 outputs. I tried "flutter pub run build_runner watch --delete-conflicting-outputs" after I read a post with the same problem in StackOverFlow but still the file won't be generated. What do you recommend to do?
Hello, Nawaf! Follow this link: stackoverflow.com/questions/59668548/why-doesnt-build-runner-generate-files-when-serializing-json-in-dart-flutter I hope it will solve your problem. Thank You 🙂
Hello dears. I cloned this app to my PC and I add some data to it. When I close and restart it, no data is shown. Is it normal. Couldn't I use Hive as a normal database for flutter web app?
Thanks, Frankee! 🙂 Yes, it is similar, however, using Hive is more convenient, especially if you use the save and delete methods such as pointed out at 13:15 and 14:17. Hive also supports encryption and easy ways to display the data asynchronously in your UI. Learn more about it here: docs.hivedb.dev/#/../best-practices/when_to_use_hive?id=when-to-use-hive
Great video with easy to understand explanation. But the sample app fails to work when closed and reopened; throws the error "LateInitializationError: Field 'amount' has not been initialized." on (package:hive_database_example/page/transaction_page.dart:59:43). Except for this, it is a great tutorial to get a kick-start on Hive !!!
@@HeyFlutter Hi Johannes. Thanks for the tut. After changing with ? Im getting "The argument type 'double?' can't be assigned to the parameter type 'num'." in transaction page. so adding "!" variable names causing different errors. Could you help ? Thanks.
@@HeyFlutter Got it running once, and debugged the heck out of my flutter versions until I found that comment. All those late vars fail at some point. Making them nullable is no solution, since there are follow up errors when using the vars. Not easy to fix, if you are not proficient with null-safety (I come from pre 2.0 flutter). It would be very nice to provide a fix on github, since this tutorial seems to be good. Sind doch bloß 10min für dich ;-)
Hello, ViKARLL! Follow this link: stackoverflow.com/questions/67401385/lateinitializationerror-field-data-has-not-been-initialized-got-error, I hope it will solve your problem. Thank You 🙂
What if I decided to remove the parameter and the example: remove HiveField(1) ? then change it to a different parameter, but with same HiveField(1)...?
Thank You Keith Bacalso! Follow this link: medium.flutterdevs.com/hive-database-with-typeadapter-in-flutter-7390d0e515fa I hope you will get your answer 🙂
I have a video request. Can you make a crud application that stores data in the local database if there is no internet , when we have internet connection the same data is transferred to the online database in the background.
If I just have a fromJson and toJson in my models, that coverts my class to a Map, can I just store and retrieve these Maps without modify my class adding annotations and using build runner? I have classes with a lots of attributes.
@@HeyFlutter Can I just convert my classes to Map to store and retrieve data from hive, without need to use those annotations and build runner? Isnt it more easy?
How can we add a list in the model class in hive? Do we have to register an adapter for the myobject class as well as for the model class? Is the way of registering adapter for myobject similiar to that of model class?
Thank You Anugrah Kora! Follow this link: stackoverflow.com/questions/59413228/how-to-save-a-listobject-and-retrieve-using-hive I hope you will get your answer 🙂
i did these steps but i have a problem saying: Bad state: No definition of type List [SEVERE] Failed after 501ms pub finished with exit code 1 what Should i do?
Thank You Samuel Onyedikachukwu Akujor! Follow this link: medium.com/flutter-community/storing-local-data-with-hive-and-provider-in-flutter-a49b6bdea75a I hope you will get your answer 🙂
Yup ! I ran into a problem and now I think I see why we need the Type Adapters ... Correct me if I'm wrong, but that's to help us save different Model types directly?
Hello Johannes, I followed your tutorial but I got the error " Box not found. Did you forget to call Hive.openBox()?." I have already open box in main.dart file is the same as yours. Please give me any hints why this happened.
Thank You Dipali Thakare! Follow this link: stackoverflow.com/questions/59436867/box-not-found-did-you-forget-to-call-hive-openbox I hope you will get your answer 🙂
Hi Johannes, awesome work! Thank you for your great content! I'm on a project right now and looking for a possibility to add data to only one field of a Box with seven fields. Is that Possible? Hive is really great to use but this is something I stuck with... Is there any solution for it? I'm really looking forward to your answer. Greetings from Germany :)
When i run flutter packages pub run build_runner build. .g.dart isn't generating. What should i do to fix this i tried flutter clean | flutter pub get | flutter packages pub run build_runner build --delete-conflicting-outputs nothing works
Hello, Hadi Khan! Follow this link: stackoverflow.com/questions/58360475/flutter-json-serialization-not-generating-g-dart-files, I hope it will solve your problem. Thank You 🙂
When I restart the closed app, I get the "LateInitializationError: Field 'amount' has not been initialized' error. I've looked at the links as noted in the comments below, but I don't see where the error is occurring or how to fix it. Anyone been able to resolved/fix this error?? If so, how.
Thank You Supernova! Follow this link: itnext.io/flutter-save-data-to-local-storage-with-hive-nosql-database-package-8a0de834f313?gi=2729f591701 I hope you will get your answer 🙂
Hey my question is do I need to ask for permission from user something like internal storage permission etc, or I can simply use it without permission as it is and in what file format it stores your data and where 🙄🙄 please help me out
@@HeyFlutter does this package will do those things automatically?? Or I need to write some code btw thanku so much ❤️❤️❤️❤️ you're doing fabulous work and also helping beginners like me 👍
Thank you, old men! 🙂 Well you are write we have to provide storage permissions. Hive makes use of storage path to store data in a particular directory. You need not to provide permissions explicitly you can make use of this package : pub.dev/packages/path_provider to access storage path as well as requesting permission
Thank You NISHANT SHARMA! Follow this link: stackoverflow.com/questions/71920274/how-to-fix-hive-box-already-open-error-in-flutter I hope you will get your answer 🙂
Thank You @andreasacca7971! Follow this link: stackoverflow.com/questions/64272936/how-to-filter-hive-data-in-flutter-by-data-values I hope you will get your answer 🙂
Hi johanness , I've got this error : LateInitializationError: Field 'amount' has not been initialized. how can I solve it ? i havent add anything to your code ...it was fine yesterday but today ive tried to connect the project from vs code to the emualtor i got this error ... i would really appreciate your help on that .
Hello, delaram majestic! Follow this link: stackoverflow.com/questions/67040839/flutter-lateinitializationerror-field-name-has-not-been-initialized, I hope it will solve your problem. Thank You 🙂
Have you ever worked with hive and nested data? I'm doing a project where I was trying to do nesting and lists. For my project I'm initially creating content to a box similar to you but I also have a list eg: String name List items The items are empty in the beginning when creating the entry to the box and I'm planning on populate the item list in your "edit" section, eg entering the item number and quantity followed by "save" which is supposed to save the data to the list for the entry in the box. Adding more entries on the "edit" page will add-on to the list of items. I then want to see the list of items in a scrollable list on the "edit" section for that entry but I can't seem to make it work. For starters I can't seem to populate the list and it seems very hard making the List items listenable in an ValueListenableBuilder. Have you ever worked like this before? Any Ideas?
Thank You Jim Sundqvist! Follow this link: medium.com/nonstopio/best-local-database-for-flutter-hive-part-3-3a87fac526a5 I hope you will get your answer 🙂
Thank You Vidyasagar Gaikwad! Follow this link: viveky259259.medium.com/hive-for-flutter-1-when-why-database-cea0013c9fc1 I hope you will get your answer 🙂
fantastic tutorial as usual, but in all honesty i feel this is sooo much coding for a DB that's neck to neck with Shared Preferences, Sure Hive has an advantage but still...
@@HeyFlutter [WARNING] hive_generator:hive_generator on lib/DataModel/ImageModel.dart: ImageModel.g.dart must be included as a part directive in the input library with: part 'ImageModel.g.dart'; cannot solve .
Thank You Arsh Ansari! Follow this link: stackoverflow.com/questions/58023664/flutter-pub-run-build-runner-build-failed I hope you will get your answer 🙂
So i have the question. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-w8cZKm9s228.html you have function type 'Future', but func returns nothing. My IDE starts to swear at me at theat moment. How do yo make it happen? If you write type of function you must return that type in function body. Isnt it?
Thank You Hakan Akgül! Follow this link: stackoverflow.com/questions/65168612/how-to-put-data-to-hivedb-after-fetching-it-from-the-firebase-and-access-data-f I hope you will get your answer 🙂