Skip to content

Commit

Permalink
Fix setState called in a build method (#4438)
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k authored Aug 4, 2023
1 parent 29e2ec4 commit 13e6d54
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/smooth_app/lib/pages/carousel_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ExternalCarouselManager extends StatefulWidget {
class ExternalCarouselManagerState extends State<ExternalCarouselManager> {
final CarouselController _controller = CarouselController();

String? _currentBarcode;
String? currentBarcode;

@override
Widget build(BuildContext context) {
Expand All @@ -60,13 +60,8 @@ class ExternalCarouselManagerState extends State<ExternalCarouselManager> {

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;
}
}

Expand Down

0 comments on commit 13e6d54

Please sign in to comment.