Sitelet https://github.com/flutter/flutter/pull/189111
Skip to content

Migrate to listen package - #189111

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
chunhtai:migrate-listen
Aug 31, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
chunhtai:migrate-listen

Conversation

@chunhtai

@chunhtai chunhtai commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

as title

will publish stable for listen package once this is approved

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 8, 2026
@chunhtai chunhtai added the CICD Run CI/CD label Jul 8, 2026
@github-actions github-actions Bot added a: tests "flutter test", flutter_test, or one of our tests tool Affects the "flutter" command-line tool. See also t: labels. labels Jul 10, 2026
@chunhtai
chunhtai force-pushed the migrate-listen branch 3 times, most recently from dc49b21 to 7b24f9b Compare July 14, 2026 02:59
@github-actions github-actions Bot removed a: tests "flutter test", flutter_test, or one of our tests tool Affects the "flutter" command-line tool. See also t: labels. labels Jul 14, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 16, 2026
Comment thread dev/bots/docs.sh
# When updating to a new dartdoc version, please also update
# `dartdoc_options.yaml` to include newly introduced error and warning types.
"$DART" pub global activate dartdoc 9.0.0
"$DART" pub global activate dartdoc 9.0.6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example directive support is added in 9.0.6, this is needed in order to build listen doc which pull into the main doc by the dartdoc

/// framework.
library foundation;

export 'dart:ui' show VoidCallback;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was exported by changenotifier before

@chunhtai
chunhtai marked this pull request as ready for review July 16, 2026 03:58
@chunhtai
chunhtai requested review from justinmc and loic-sharma July 16, 2026 03:59

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the internal implementation of ChangeNotifier and related classes in the foundation library with exports from the external listen package, updating dependencies and allowlists accordingly. Feedback on the changes suggests removing the redundant and eager initialization of Listenable hooks in BindingBase to avoid conflicts and performance overhead. Additionally, it is recommended to lazily set up these hooks in FlutterMemoryAllocations only when memory allocation tracking is enabled, and to use 'foundation' as the library name for consistency.

Comment thread packages/flutter/lib/src/foundation/binding.dart Outdated
Comment thread packages/flutter/lib/src/foundation/memory_allocations.dart
Comment thread packages/flutter/pubspec.yaml Outdated
Comment thread packages/flutter/lib/src/foundation/binding.dart Outdated
library: 'foundation library',
context: ErrorDescription('while dispatching notifications for $Listenable'),
),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a default case? Otherwise, adding a new ErrorContext enum value would be a breaking change here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flutter suggest not to use default

Analyzing Flutter repository...                                     4.9s


   info • Invalid use of 'default' member in a switch. Try enumerating all the possible values of the switch expression • packages/flutter/lib/src/foundation/binding.dart:314:9 • no_default_cases

@loic-sharma loic-sharma Aug 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with no_default_cases for enums that are declared in the Flutter SDK, but I'm not sure that I agree in this instance where the enum is in a separate package that the Flutter SDK depends on. A user can use an old version of the Flutter SDK with a newer version of package:listen.

The benefit of a default case is that we guarantee our logic handles all known enum cases. However, I don't think that benefit outweighs the drawback that adding a new enum value would be a breaking change that forces you to upgrade your Flutter SDK. I still lean towards using a default case here and suppressing no_default_cases. Let me know if I'm missing anything here though!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree to use default case in general since it can potentially make things fail silently. For this case, it is probably fine since this is mostly just for logging and report error, but i still would like to follow the lint and not use default case just because i don't want to add a ignore and confuse people

@loic-sharma loic-sharma Aug 10, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure the problem is clear: if we omit the default case and we add a new ErrorContext enum value, running flutter pub upgrade on your app will result in compilation errors. You'll also get compilation errors if you flutter create using an old Flutter SDK. You will need to either add a version constraint on package:listen, or, upgrade to a Flutter SDK that handles the new value (if one exists, which it might not yet due to the SDK's quarterly release cadence). This seems like a painful situation that we should avoid.

... but i still would like to follow the lint and not use default case just because i don't want to add a ignore and confuse people

Instead of failing silently, we could fallback to a FlutterError.reportError with a context like ErrorDescription('in an unknown location')? And to make it easier to remember to update this switch, we could update package:listenable's ErrorContext to add a // comment that if you add a new value to the enum, you must update the framework's Listenable.onError callback. What would you think of this approach?

Comment thread dev/bots/docs.sh
loic-sharma
loic-sharma previously approved these changes Jul 18, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! I left some minor nitpicks and questions :)

@chunhtai

Copy link
Copy Markdown
Contributor Author

google test fails because it require the listen package to be roll in first as the internal flutter sdk doesn't have access to pub

@chunhtai
chunhtai force-pushed the migrate-listen branch 2 times, most recently from bce695b to 8096439 Compare August 6, 2026 02:04
@chunhtai
chunhtai requested a review from loic-sharma August 6, 2026 02:13

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-LGTM but I still lean towards adding a default case for the ErrorContext switch (comment).

@chunhtai

Copy link
Copy Markdown
Contributor Author

still working on internal migration. it is a lot involved than I think, lots of code directly import the source file change_notifier.dart. I have been fixing them as well as build files

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

AssertionError(message: final Object? msg) => msg?.toString() ?? error.toString(),
_ => error.toString(),
};
throw FlutterError(message);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we lose the stacktrace here?

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit

auto-submit Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189111, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 31, 2026
Merged via the queue into flutter:master with commit 5149053 Aug 31, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 1, 2026
flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

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
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12712)

flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

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
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12712)

flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

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
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

Development

Successfully merging this pull request may close these issues.

4 participants