⚠️ Formatting & analysisTo get full marks for the task, your code must be properly formatted and must not produce any analysis issues. That is, running the following commands in the week's directory must not report any issues or changes:
dart format --output=none --set-exit-if-changed . flutter analyze
Check out the hosted example solution to play around with the implemented features.
Implement the TodoDataSource
using four different persistence methods.
Data source features to implement:
- List all Todos
- Get a Todo by ID
- Insert a new Todo
- Remove Todo by ID
- Update a Todo with new data
Implement the InMemoryTodoDataSource
. Store the data in a collection inside the object.
This kind of persistence isn't very persistent, but it's still useful sometimes.
- Implement the
DriftTodoDataSource
using a Drift SQL database. - Follow the steps in the official documentation.
- Use the existing
Todo
class as the model (drift would generate its own otherwise). Use the@UseRowClass
annotation for this.
Packages:
- Implement the
HiveTodoDataSource
using a Hive box. - To store custom objects in Hive, you need to use a TypeAdapter.
You can generate one using the
hive_generator
package, or write one manually (I recommend this option for not-so-complicated types).
Packages:
hive
hive_flutter
- Optionally
hive_generator
for code generation
⚠️ Why not Isar?Isar is the successor of Hive, and thus is recommended instead of it. However, the current 3.x versions don't support running on the Web (Hive does).
- Implement the
LocalstoreTodoDataSource
using the Localstore database. - Localstore is JSON-based, so it can only store serialized data (like Firestore).
Packages:
- Write tests for the TodoCubit.
- Test each method – ensure it emits correct states.
- Also verify that appropriate methods of the data source are called.
- Verify that a
TodoTile
is properly displayed- Verify that the Todo's title is visible
- Verify that a done Todo displays a checked checkbox, and that an undone Todo displays an empty checkbox
- Verify that the
HomePage
contains all four possible cards (i.e., aCard
with an appropriate text inside for each option)