-
Let's say I have a widget that watches a table: class MyApp extends StatefulWidget {
const MyApp(this.db, {super.key});
final AppDatabase db;
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late final stream = widget.db.select(widget.db.todoItems).watch();
@override
Widget build(BuildContext context) {
// ...
}
} If I test that widget like so: void main() {
late AppDatabase db;
setUpAll(() {
db = AppDatabase();
});
tearDownAll(() {
db.close();
});
testWidgets('MyApp', (tester) async {
await tester.pumpWidget(MyApp(db));
});
} I will get this error:
The only way to fix it, is to move the Is there a better way of doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In the next drift version, you'll be able to use |
Beta Was this translation helpful? Give feedback.
In the next drift version, you'll be able to use
DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)
to fix this issue.