Skip to content

Simple yet powerful and fun task app with Floor package

Notifications You must be signed in to change notification settings

CorneilleEdi/floor_task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published