diff --git a/moor_flutter/example/lib/bloc.dart b/moor_flutter/example/lib/bloc.dart index 5a8e1c82..b61851b5 100644 --- a/moor_flutter/example/lib/bloc.dart +++ b/moor_flutter/example/lib/bloc.dart @@ -19,14 +19,14 @@ class TodoAppBloc { final BehaviorSubject _activeCategory = BehaviorSubject.seeded(null); - Observable> _currentEntries; + Stream> _currentEntries; /// A stream of entries that should be displayed on the home screen. - Observable> get homeScreenEntries => _currentEntries; + Stream> get homeScreenEntries => _currentEntries; final BehaviorSubject> _allCategories = BehaviorSubject(); - Observable> get categories => _allCategories; + Stream> get categories => _allCategories; TodoAppBloc() : db = Database() { // listen for the category to change. Then display all entries that are in @@ -35,7 +35,7 @@ class TodoAppBloc { // also watch all categories so that they can be displayed in the navigation // drawer. - Observable.combineLatest2, Category, + Rx.combineLatest2, Category, List>( db.categoriesWithCount(), _activeCategory, diff --git a/moor_flutter/example/lib/database/database.dart b/moor_flutter/example/lib/database/database.dart index 255a602d..65e3909a 100644 --- a/moor_flutter/example/lib/database/database.dart +++ b/moor_flutter/example/lib/database/database.dart @@ -126,7 +126,7 @@ class Database extends _$Database { return rows.map((row) { return EntryWithCategory( row.readTable(todos), - row.readTable(categories), + row.readTableOrNull(categories), ); }).toList(); }); diff --git a/moor_flutter/example/lib/database/database.g.dart b/moor_flutter/example/lib/database/database.g.dart index f7c332f9..09a02729 100644 --- a/moor_flutter/example/lib/database/database.g.dart +++ b/moor_flutter/example/lib/database/database.g.dart @@ -503,9 +503,9 @@ abstract class _$Database extends GeneratedDatabase { variables: [], readsFrom: {categories, todos}).map((QueryRow row) { return CategoriesWithCountResult( - id: row.readInt('id'), - desc: row.readString('desc'), - amount: row.readInt('amount'), + id: row.read('id'), + desc: row.read('desc'), + amount: row.read('amount'), ); }); } diff --git a/moor_flutter/example/lib/widgets/add_category_dialog.dart b/moor_flutter/example/lib/widgets/add_category_dialog.dart index eeb0e967..5383b9d3 100644 --- a/moor_flutter/example/lib/widgets/add_category_dialog.dart +++ b/moor_flutter/example/lib/widgets/add_category_dialog.dart @@ -50,7 +50,8 @@ class _AddCategoryDialogState extends State { void _addEntry() { if (_controller.text.isNotEmpty) { - Provider.of(context).addCategory(_controller.text); + Provider.of(context, listen: false) + .addCategory(_controller.text); Navigator.of(context).pop(); } } diff --git a/moor_flutter/example/lib/widgets/categories_drawer.dart b/moor_flutter/example/lib/widgets/categories_drawer.dart index 895b948b..3cd27053 100644 --- a/moor_flutter/example/lib/widgets/categories_drawer.dart +++ b/moor_flutter/example/lib/widgets/categories_drawer.dart @@ -101,7 +101,7 @@ class _CategoryDrawerEntry extends StatelessWidget { title: const Text('Delete'), content: Text('Really delete category $title?'), actions: [ - FlatButton( + TextButton( child: const Text('Cancel'), onPressed: () { Navigator.pop(context, false); diff --git a/moor_flutter/example/lib/widgets/homescreen.dart b/moor_flutter/example/lib/widgets/homescreen.dart index 18908a6e..bbd693be 100644 --- a/moor_flutter/example/lib/widgets/homescreen.dart +++ b/moor_flutter/example/lib/widgets/homescreen.dart @@ -21,7 +21,7 @@ class HomeScreenState extends State { // been added final TextEditingController controller = TextEditingController(); - TodoAppBloc get bloc => Provider.of(context); + TodoAppBloc get bloc => Provider.of(context, listen: false); @override Widget build(BuildContext context) { @@ -33,6 +33,8 @@ class HomeScreenState extends State { body: StreamBuilder>( stream: bloc.homeScreenEntries, builder: (context, snapshot) { + print(snapshot); + if (!snapshot.hasData) { return const Align( alignment: Alignment.center, diff --git a/moor_flutter/example/pubspec.yaml b/moor_flutter/example/pubspec.yaml index 3ad92fa6..0d102b12 100644 --- a/moor_flutter/example/pubspec.yaml +++ b/moor_flutter/example/pubspec.yaml @@ -10,14 +10,14 @@ environment: dependencies: flutter: sdk: flutter - provider: ^3.2.0 - intl: ^0.16.0 - rxdart: 0.21.0 - moor_flutter: ^3.0.0 + provider: ^5.0.0 + intl: ^0.17.0 + rxdart: ^0.26.0 + moor_flutter: ^4.0.0 dev_dependencies: build_runner: - moor_generator: ^3.2.0 + moor_generator: ^4.0.0 flutter_test: sdk: flutter