From e19bf9de6cac5a6a812437a4210ba5acf1f80234 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 4 Aug 2023 14:01:21 +0200 Subject: [PATCH] Fix setState called in a `build` method --- packages/smooth_app/lib/pages/carousel_manager.dart | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/smooth_app/lib/pages/carousel_manager.dart b/packages/smooth_app/lib/pages/carousel_manager.dart index d7ac7c23b53..249a9cd0e65 100644 --- a/packages/smooth_app/lib/pages/carousel_manager.dart +++ b/packages/smooth_app/lib/pages/carousel_manager.dart @@ -34,7 +34,7 @@ class ExternalCarouselManager extends StatefulWidget { class ExternalCarouselManagerState extends State { final CarouselController _controller = CarouselController(); - String? _currentBarcode; + String? currentBarcode; @override Widget build(BuildContext context) { @@ -60,13 +60,8 @@ class ExternalCarouselManagerState extends State { CarouselController get controller => _controller; - String? get currentBarcode => _currentBarcode; - - set currentBarcode(String? barcode) => - setState(() => _currentBarcode = barcode); - bool updateShouldNotify(ExternalCarouselManagerState oldState) { - return oldState.currentBarcode != _currentBarcode; + return oldState.currentBarcode != currentBarcode; } }