Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shared_preferences]Fix : SetState returning future (#8398)
This pull request includes a change to the `SharedPreferencesDemoState` class in the `main.dart` file. The change improves the way the external counter value is fetched and updated in the state. * [`packages/shared_preferences/shared_preferences/example/lib/main.dart`](diffhunk://#diff-6e8eaf30aa7259bf259f36e9c2057d82498b436c508f202521b4f8808788c15bL59-R61): Refactored the `_getExternalCounter` method to fetch the external counter value before calling `setState`, ensuring that asynchronous operations are handled correctly. The issue was : ``` FlutterError (setState() callback argument returned a Future. The setState() method on SharedPreferencesDemoState#1acdd(lifecycle state: created) was called with a closure or method that returned a Future. Maybe it is marked as "async". Instead of performing asynchronous work inside a call to setState(), first execute the work (without updating the widget state), and then synchronously update the state inside a call to setState().) ```
- Loading branch information