-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[shared_preferences]Fix : SetState returning future #8398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[shared_preferences]Fix : SetState returning future #8398
Conversation
… change on the iOS platform. (flutter#8203) Added a listener callback for the canGoBack property on iOS. Since it can only be effectively implemented on iOS, it is only exposed in the WKWebView layer. Fixes flutter/flutter#158160 *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] page, which explains my responsibilities. - [ ] I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use `dart format`.) - [ ] I signed the [CLA]. - [ ] The title of the PR starts with the name of the package surrounded by square brackets, e.g. `[shared_preferences]` - [ ] I [linked to at least one issue that this PR fixes] in the description above. - [ ] I updated `pubspec.yaml` with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes]. - [ ] I updated `CHANGELOG.md` to add a description of the change, [following repository CHANGELOG style], or this PR is [exempt from CHANGELOG changes]. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [relevant style guides]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [linked to at least one issue that this PR fixes]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [pub versioning philosophy]: https://dart.dev/tools/pub/versioning [exempt from version changes]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version [following repository CHANGELOG style]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style [exempt from CHANGELOG changes]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@stuartmorgan can you exempt this from versioning? (If you agree that's appropriate) |
example/lib/main.dart is published on pub.dev, which is why the CI check explicitly doesn't exempt this file in its check. The exemption is for "PRs that only affect unpublished parts of example apps." That's covered in the PR checklist, which I've restored to the PR description. @berhili098, in the future please don't delete the checklist, as it's there for a reason. I'm marking this as a draft for now; please complete the checklist and then mark it as ready for review once that's done. |
… in `exemple/main.dart`
…` to `example/main.dart`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the versioning to match the documented style guide
tarrinneal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan for second review
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
flutter/packages@625023a...8542af3 2025-02-15 stuartmorgan@google.com [various] Enable `permissive-` for Windows plugin examples (flutter/packages#8636) 2025-02-15 stuartmorgan@google.com [pigeon] Update task queue handling (flutter/packages#8627) 2025-02-14 goderbauer@google.com Update CODEOWNERS (flutter/packages#8628) 2025-02-14 32538273+ValentinVignal@users.noreply.github.com [flutter_adaptive_scaffold] Fix some memory leaks (flutter/packages#8546) 2025-02-14 mchudy@users.noreply.github.com [camera] Fix crash when setting activeFormat on FLTCaptureDevice (flutter/packages#8630) 2025-02-13 mchudy@users.noreply.github.com [camera] Remove remaining OCMock usage in tests (flutter/packages#8624) 2025-02-13 10687576+bparrishMines@users.noreply.github.com [webview_flutter_wkwebview] Change callback methods with a non-null return type to non-null (flutter/packages#8564) 2025-02-12 737941+loic-sharma@users.noreply.github.com [google_sign_in_ios] Adds Swift Package Manager support (flutter/packages#7356) 2025-02-12 pawel.jakubowski@leancode.pl [camera_avfoundation] Migrate tests to Swift - part 1 (flutter/packages#8603) 2025-02-12 43054281+camsim99@users.noreply.github.com [video_player] Re-enables `asset videos live stream duration != 0` test for Android (flutter/packages#8610) 2025-02-12 32538273+ValentinVignal@users.noreply.github.com [go_router_builder] Add support for `TypedStatefulShellBranch`'s `preload` (flutter/packages#8587) 2025-02-12 magder@google.com [local_auth_darwin] Fix test name for clarity (flutter/packages#8499) 2025-02-11 ditman@gmail.com [ci] Manually roll master, set -Xmx4G (flutter/packages#8586) 2025-02-11 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump the gradle-plugin group across 4 directories with 1 update (flutter/packages#8551) 2025-02-10 10687576+bparrishMines@users.noreply.github.com [pigeon] Add errors for ProxyAPI callback methods and null instances when reading in a ProxyApiBaseCodec (flutter/packages#8567) 2025-02-10 98884136+berhili098@users.noreply.github.com [shared_preferences]Fix : SetState returning future (flutter/packages#8398) 2025-02-10 stuartmorgan@google.com [various] Add deprecation notices to READMEs (flutter/packages#8598) 2025-02-10 mchudy@users.noreply.github.com [camera] Remove OCMock from CameraSettingsTests, CameraMethodChannelTests and CameraSessionPresetsTests (flutter/packages#8592) 2025-02-10 mchudy@users.noreply.github.com [camera] Remove OCMock from FLTCamPhotoCaptureTests, FLTSavePhotoDelegateTests and StreamingTests (flutter/packages#8590) 2025-02-07 32538273+ValentinVignal@users.noreply.github.com [go_router] Add `preload` parameter to `StatefulShellBranchData.$branch` (flutter/packages#8545) 2025-02-07 pawel.jakubowski@leancode.pl [video_player_avfoundation] iOS platform view support (flutter/packages#8237) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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().) ```
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().) ```
This pull request includes a change to the
SharedPreferencesDemoStateclass in themain.dartfile. 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: Refactored the_getExternalCountermethod to fetch the external counter value before callingsetState, ensuring that asynchronous operations are handled correctly.The issue was :
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.