FlutterMay 5, 2024 · 10 min read
Building a Notes App with Flutter & Hive
A step-by-step tutorial on building a fast, offline-first notes app using Hive for local storage.
E
Evan Emran
Mobile Developer & Tech Blogger
Why Hive?
Hive is a lightweight, blazing-fast key-value database written in pure Dart. It is perfect for offline-first apps.
Setup
dependencies:
hive: ^2.2.3
hive_flutter: ^1.1.0
Initializing Hive
await Hive.initFlutter();
final box = await Hive.openBox('notes');
Saving and Reading Notes
await box.put('note-1', 'Buy milk');
final note = box.get('note-1');
With a ValueListenableBuilder on the box, your UI updates automatically whenever the data changes.