Why I Built a Simple App to Understand Isar in Flutter (And the Challenges I Faced)
When learning a new tool or technology, everyone usually tries to build massive projects like e-commerce apps or social media clones. Instead, I turned to a much more focused and simple project to wrap my head around a new local database solution: a Minimalist Habit Tracker . My goal was to focus directly on database operations and state management integration without getting lost in complex UI…
When learning a new tool or technology, many people attempt grand projects like e-commerce or social media applications. However, to truly grasp a new local database solution, I chose a simpler project: a Minimalist Habit Tracker. The objective was to concentrate on database operations and state management integration without being overwhelmed by intricate UI designs or API integrations. This led me to explore Isar, a fast, type-safe NoSQL database crafted by Simon Leier, the creator of the renowned Hive package.
For those unfamiliar, Isar stands out due to its speed, safety, and advanced querying capabilities. It boasts lightning-fast read/write times, type-safe queries that prevent string-based errors, and advanced features such as full-text search, filtering, and multi-indexing. Moreover, the Visual Inspector allows real-time database observation through a browser interface, akin to an Excel spreadsheet.
To maintain code clarity, I adopted a divide-and-conquer strategy. The project architecture comprised:
- Models: Habit class utilizing Isar's capabilities.
- Services: A dedicated layer managing CRUD operations and updates.
- Providers: HabitProvider connecting the UI with the Isar service.
- Screens: A clean, minimalist interface for user interaction.
Despite initial optimism, several challenges emerged during development:
1. The Gradle and Namespace Rebellion: The initial installation of Isar triggered errors due to the isar_flutter_libs package's namespace violation and minimum SDK requirement. To resolve this, I manually added the necessary namespace to the package's android/build.gradle file and updated the compileSdkVersion to 34.
2. Provider's Silent Scream: Saving a new habit from the UI resulted in crashes, specifically due to a "T != dynamic" error. This was resolved by strictly specifying the HabitProvider type in the context.read() function call.
3. GitHub Thinking My Project was an HTML Project: Pushing the project to GitHub revealed a language composition of 7% Dart and 90% HTML. To rectify this, I created a .gitattributes file, instructing GitHub to ignore specific autogenerated folders, thus restoring the project's accurate language statistics.
Through this experience, I learned the value of abstracting complex technologies into their simplest forms to facilitate understanding. My project and code are available at the following GitHub repository for further review and feedback.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.