0% found this document useful (0 votes)
34 views13 pages

Flutter Hive Chapter 8

Hive is a lightweight NoSQL key-value database designed for Flutter and Dart applications, ideal for local data storage and offline access. It features fast performance, strong typing with type adapters, and cross-platform compatibility. The document outlines the steps to integrate Hive into a Flutter project, including adding dependencies, creating classes, and performing basic data operations.

Uploaded by

marahazzam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views13 pages

Flutter Hive Chapter 8

Hive is a lightweight NoSQL key-value database designed for Flutter and Dart applications, ideal for local data storage and offline access. It features fast performance, strong typing with type adapters, and cross-platform compatibility. The document outlines the steps to integrate Hive into a Flutter project, including adding dependencies, creating classes, and performing basic data operations.

Uploaded by

marahazzam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

1

Eyad Alshareef - Flutter and Dart


Hive : Store
Data locally
EYAD ALSHAREEF
2
Hive in Flutter

 Hive refers to a  Hive is a fast and lightweight


lightweight and efficient key-value database.
NoSQL database that is  It is a great choice for storing
designed specifically for small amounts of data locally,
such as user preferences, game
Flutter and Dart
scores, or shopping carts.
applications.
 Hive is also a good option for
apps that need to be able to
work offline.
Eyad Alshareef - Flutter and Dart
3
Hive in Flutter- Key Properties

• Key-Value Store: Hive stores data as key-value pairs, similar to a dictionary or


map.
• NoSQL: It's a NoSQL database, meaning it doesn't use traditional relational
database structures like tables and SQL.
• Local Storage: Hive stores data locally on the device, making it ideal for offline
access and quick data retrieval.
• Fast and Efficient: Hive is designed for speed and efficiency, making it suitable for
even complex Flutter applications.
• Strongly Typed: Hive uses type adapters to ensure type safety, preventing
common data corruption issues.
• Cross-Platform: Works on various platforms supported by Flutter (iOS, Android,
Web, Desktop).
Eyad Alshareef - Flutter and Dart
4
Hive in Flutter- Key Properties

Eyad Alshareef - Flutter and Dart


5
Hive in Flutter- steps

1- Add Dependencies: Add the


hive and hive_flutter packages
to your pubspec.yaml file:

Run flutter pub get to install


the packages.

Eyad Alshareef - Flutter and Dart


6
Hive in Flutter- steps

2- Create Class [Box-Table]


and generate adapter
New file with the same as
class name that represent
the Box[table]

Eyad Alshareef - Flutter and Dart


7
Hive in Flutter- steps

3- Auto generate the class.g:


in terminal Run the
command
Run
flutter packages pub
run build_runner build
to create the class

Eyad Alshareef - Flutter and Dart


8
Hive in Flutter- steps

4- Initialize Hive and register


the adapter in main
Function(main.dart)

Eyad Alshareef - Flutter and Dart


9
Hive in Flutter- steps

5- Open The Box[table] and create a Box file

BoxUSER = await Hive.openBox<ClassName>('myUsers'); //open box

Eyad Alshareef - Flutter and Dart


10
Hive in Flutter- steps

7- PUT data into the Box[table] 


[Insert, update]

Eyad Alshareef - Flutter and Dart


11
Hive in Flutter- steps

8- GET data from the Box[table] 


[Select]

Eyad Alshareef - Flutter and Dart


12
Hive in Flutter- steps

9- Delete data from the Box[table] 


[delete]

Eyad Alshareef - Flutter and Dart


13
Hive in Flutter- steps
10- Other methods

Eyad Alshareef - Flutter and Dart

You might also like