diff --git a/lib/src/shared/controllers/order_controller.dart b/lib/src/shared/controllers/order_controller.dart index a5ee230..e283f05 100644 --- a/lib/src/shared/controllers/order_controller.dart +++ b/lib/src/shared/controllers/order_controller.dart @@ -7,6 +7,12 @@ class OrderController { return await orderRepository.get(); } + Stream getLikeStream() async* { + yield* Stream.periodic( + const Duration(seconds: 3), (_) => orderRepository.get()) + .asyncMap((event) async => await event); + } + Future post(List idItem) async { await orderRepository.post(idItem); } diff --git a/lib/src/views/admin/screen/home/home_screen.dart b/lib/src/views/admin/screen/home/home_screen.dart index 5797511..2ac8699 100644 --- a/lib/src/views/admin/screen/home/home_screen.dart +++ b/lib/src/views/admin/screen/home/home_screen.dart @@ -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(