|
1 | 1 | import 'package:flutter/material.dart';
|
2 | 2 | import 'package:powersync/powersync.dart';
|
3 |
| -import 'package:powersync_flutter_demo/powersync.dart'; |
| 3 | +import 'package:powersync_flutter_demo/widgets/guard_by_sync.dart'; |
4 | 4 |
|
5 | 5 | import './list_item.dart';
|
6 | 6 | import './list_item_dialog.dart';
|
@@ -46,29 +46,23 @@ final class ListsWidget extends StatelessWidget {
|
46 | 46 |
|
47 | 47 | @override
|
48 | 48 | Widget build(BuildContext context) {
|
49 |
| - return FutureBuilder( |
50 |
| - future: db.waitForFirstSync(priority: _listsPriority), |
51 |
| - builder: (context, snapshot) { |
52 |
| - if (snapshot.connectionState == ConnectionState.done) { |
53 |
| - return StreamBuilder( |
54 |
| - stream: TodoList.watchListsWithStats(), |
55 |
| - builder: (context, snapshot) { |
56 |
| - if (snapshot.data case final todoLists?) { |
57 |
| - return ListView( |
58 |
| - padding: const EdgeInsets.symmetric(vertical: 8.0), |
59 |
| - children: todoLists.map((list) { |
60 |
| - return ListItemWidget(list: list); |
61 |
| - }).toList(), |
62 |
| - ); |
63 |
| - } else { |
64 |
| - return const CircularProgressIndicator(); |
65 |
| - } |
66 |
| - }, |
67 |
| - ); |
68 |
| - } else { |
69 |
| - return const Text('Busy with sync...'); |
70 |
| - } |
71 |
| - }, |
| 49 | + return GuardBySync( |
| 50 | + priority: _listsPriority, |
| 51 | + child: StreamBuilder( |
| 52 | + stream: TodoList.watchListsWithStats(), |
| 53 | + builder: (context, snapshot) { |
| 54 | + if (snapshot.data case final todoLists?) { |
| 55 | + return ListView( |
| 56 | + padding: const EdgeInsets.symmetric(vertical: 8.0), |
| 57 | + children: todoLists.map((list) { |
| 58 | + return ListItemWidget(list: list); |
| 59 | + }).toList(), |
| 60 | + ); |
| 61 | + } else { |
| 62 | + return const CircularProgressIndicator(); |
| 63 | + } |
| 64 | + }, |
| 65 | + ), |
72 | 66 | );
|
73 | 67 | }
|
74 | 68 |
|
|
0 commit comments