Skip to content

Commit

Permalink
stream order admin
Browse files Browse the repository at this point in the history
  • Loading branch information
auguzsto committed Jun 14, 2023
1 parent 9cbe213 commit 5d5add8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/src/shared/controllers/order_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class OrderController {
return await orderRepository.get();
}

Stream<List> getLikeStream() async* {
yield* Stream.periodic(
const Duration(seconds: 3), (_) => orderRepository.get())
.asyncMap((event) async => await event);
}

Future<void> post(List<String> idItem) async {
await orderRepository.post(idItem);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/views/admin/screen/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class HomeAdminScreen extends StatelessWidget {
),
),
Expanded(
child: FutureBuilder(
future: orderController.get(),
child: StreamBuilder(
stream: orderController.getLikeStream(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
Expand Down

0 comments on commit 5d5add8

Please sign in to comment.