Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Hive is a fast, secure no SQL database implementation for flutter applications. Hive database in flutter uses dart package Hive for storing data locally and manipulating the data on a targeted device.
It stands out to be very fast in performing CRUD operations in comparison to SQLite and shared preference. Hive not only supports primitives, lists, and maps but also any Dart object you like. You need to generate a type adapter before you can store objects.
An offline To-Do App is a good example where you can use the hive database. Let’s check how we can implement hive in Flutter.
Read more about our Flutter app development services.
2. Hive can store data using dart primitive types, although, in production, we deal with model objects; to deal with objects, we need to generate TypeAdapter. typeID’ is the identity of the object for the Hive to find it. HiveField must be annotated on the required field names, with their unique id in parameters.
3. Open the terminal and generate the file by entering the following: Flutter packages pub run build_runner build
4. After your .g file is generated,we have to register the adapter to be able to work with generated TYpe Adapter.
5. Open HIve box: We need to open a data box so that we can add data to it.
6. Add data in the box.
7. Read the data you have added to the database.
8. You can also update data in the database by using the putAt function and providing data you want to add an index for where you want to add your data.
9. For deleting you need to call the delete function.
That’s how we perform CRUD operations in Hive.
Output :
Thanks for reading this article ❤
If I got something wrong 🙈, let me know in the comments. I would love to improve.
You can also read: https://mobikul.com/bottom-navigation-bar-in-flutter/
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.
Josh Arnold
Owner, Shop ATV Escape
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.