CorneilleEdi / floor_task

Simple yet powerful and fun task app with Floor package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task app with Floor

this app use the Floor package

The Floor library provides a lightweight SQLite abstraction with automatic mapping between in-memory objects and database rows while still offering full control of the database with the use of SQL.

It's important to note that this library is not a full-featured ORM like Hibernate and will never be. Thus not supporting automatic relationship mapping is intentional.

Model

@entity
class Task {
  @PrimaryKey(autoGenerate: true)
  final int id;

  String title;
  
  final int createdTime;
}

Dao

@dao
abstract class TaskDao {
  @Query('SELECT * FROM task WHERE id = :id')
  Future<Task> findTaskById(int id);

  @Query('SELECT * FROM task')
  Future<List<Task>> findAllTasks();

  @Query('SELECT * FROM task')
  Stream<List<Task>> findAllTasksAsStream();

  @insert
  Future<void> insertTask(Task task);

  @update
  Future<void> updateTask(Task task);

  @delete
  Future<void> deleteTask(Task task);

  @Query('DELETE FROM task')
  Future<void> deleteAllTask();
}

Using the stream is very powerful

@Query('SELECT * FROM task')
  Stream<List<Task>> findAllTasksAsStream();
Main screeen for the list Dialog for adding a task Dialog for update a task
list list list

for the example of the provider package check the provider branch

About

Simple yet powerful and fun task app with Floor package


Languages

Language:Dart 86.3%Language:Objective-C 9.2%Language:Java 4.5%