-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental support for type converters (#318)
- Loading branch information
1 parent
fab7583
commit 5fd7cd8
Showing
68 changed files
with
2,074 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
@entity | ||
class Order { | ||
@primaryKey | ||
final int id; | ||
|
||
final DateTime date; | ||
|
||
Order(this.id, this.date); | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is Order && | ||
runtimeType == other.runtimeType && | ||
id == other.id && | ||
date == other.date; | ||
|
||
@override | ||
int get hashCode => id.hashCode ^ date.hashCode; | ||
|
||
@override | ||
String toString() { | ||
return 'Order{id: $id, date: $date}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
import 'order.dart'; | ||
|
||
@dao | ||
abstract class OrderDao { | ||
@insert | ||
Future<void> insertOrder(Order order); | ||
|
||
@Query('SELECT * FROM `Order` WHERE date = :date') | ||
Future<List<Order>> findOrdersByDate(DateTime date); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:floor/floor.dart'; | ||
import 'package:floor_annotation/floor_annotation.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:sqflite/sqflite.dart' as sqflite; | ||
|
||
import 'order.dart'; | ||
import 'order_dao.dart'; | ||
import 'type_converter.dart'; | ||
|
||
part 'order_database.g.dart'; | ||
|
||
@Database(version: 1, entities: [Order]) | ||
@TypeConverters([DateTimeConverter]) | ||
abstract class OrderDatabase extends FloorDatabase { | ||
OrderDao get orderDao; | ||
} |
Oops, something went wrong.