What is the Hive package in Flutter?
Why Interviewers Ask This
Senior Flutter engineers are expected to reason about architecture, performance, and edge cases. This question separates mid-level from senior candidates by testing deep system-level understanding.
Answer
Hive is a fast, lightweight, pure-Dart NoSQL database for local storage. It stores data in typed "boxes" (key-value stores) and uses binary serialization, making it significantly faster than SharedPreferences or SQLite for object storage. Hive requires no native dependencies, making it cross-platform. For storing custom objects, you generate a TypeAdapter using build_runner. Hive is excellent for caching API responses, storing user settings, or persisting domain objects locally. For complex queries and relationships, sqflite or Drift is more appropriate.
Common Mistake
A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.