Advertisement

Responsive Advertisement

Hive Database in Flutter

 Learn How to Create, Update, Delete and View Data using Hive Database.


What is Hive database In Flutter?

Apache Hive is a software project that enables users to perform data analysis and querying on large datasets stored in Hadoop Distributed File System or other compatible storage systems.

It was developed by Facebook and later contributed to the Apache Sofware Foundation.

In Flutter Hive is lightweight and blazing fast key - value database written in pure Dart.
Inspired by Bitcask.

HIVE: Hierarchy of International Vengeance and Extermination. 


What are Boxes in Flutter Hive Database?

All data stored in Hive is organized in boxes. A box can be compared to a table in SQL, but it does not have a structure and can contain anything. boxes are a great way to organize your data. Boxes can also be encrypted to store sensitive data.





Why us Hive Database in Flutter Mobile Application?

Hive is a lightweight and fast key-value database solution that is cross-platform (runs on mobile, desktop, and web) and is written in pure Dart. This gives it an instant advantage over SQLite, which doesn’t support Flutter web — Hive has no native dependencies, so it runs seamlessly on the web.

Getting started with Hive 
 
Let's create a simple application that stores information about our users and allows us to add, update, read, and delete data.

flutter create todo_application
Although you may open the project with any IDE, I'll be using Android Studio in this example:


Add the Hive and hive_flutter packages to your pubspec.yaml file:


dependencies:
  flutter:
    sdk: flutter

 # The following adds the Cupertino Icons font to your application.
 # Use with the CupertinoIcons class for iOS style icons.
 cupertinoIcons: ^1.0.2
 hive_generator: any
 hive: any
Your main.dart file's content should be replaced with: 

import 'package:flutter/material.dart';

main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Todo List',


import 'package:flutter/material.dart';

main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Todo List',
      theme: ThemeData(
        primarySwatch: Colors.purple,
      ),
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}
Updating....

Post a Comment

0 Comments