Add more error handling to unawaited callsites#184526
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces error reporting for asynchronous platform channel calls across the Material and Widgets libraries, specifically targeting SemanticsService.sendAnnouncement, SystemNavigator.pop, Clipboard.setData, and SensitiveContentHost methods. The changes ensure that exceptions occurring during these operations are caught and reported via FlutterError.reportError. Comprehensive unit tests were added to verify the error-handling logic. Feedback suggests refactoring duplicated error-reporting code in expansion_tile.dart into a helper function to improve maintainability.
| SemanticsService.sendAnnouncement(View.of(context), stateHint, textDirection).catchError((Object exception, StackTrace stack) { | ||
| FlutterError.reportError( | ||
| FlutterErrorDetails( | ||
| exception: exception, | ||
| stack: stack, | ||
| library: 'material library', | ||
| context: ErrorDescription('while sending semantics announcement'), | ||
| ), | ||
| ); | ||
| }); | ||
| _timer?.cancel(); | ||
| _timer = null; | ||
| }); | ||
| } | ||
| // SemanticsService.sendAnnouncement is deprecated on android. | ||
| // We use live region to achieve the announcement effect instead. | ||
| else if (defaultTargetPlatform != TargetPlatform.android) { | ||
| SemanticsService.sendAnnouncement(View.of(context), stateHint, textDirection); | ||
| SemanticsService.sendAnnouncement(View.of(context), stateHint, textDirection).catchError((Object exception, StackTrace stack) { | ||
| FlutterError.reportError( | ||
| FlutterErrorDetails( | ||
| exception: exception, | ||
| stack: stack, | ||
| library: 'material library', | ||
| context: ErrorDescription('while sending semantics announcement'), | ||
| ), | ||
| ); | ||
| }); |
There was a problem hiding this comment.
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
flutter/flutter@a0924c7...05e0ae0 2026-04-08 [email protected] Fix Android engine flags defaulting to true for malformed values (flutter/flutter#184631) 2026-04-08 [email protected] Try one more again (flutter/flutter#184767) 2026-04-08 [email protected] Remove custom `analysis_options.yaml` from `imitation_game_flutter` (flutter/flutter#184717) 2026-04-08 [email protected] Add more error handling to unawaited callsites (flutter/flutter#184526) 2026-04-08 [email protected] Refactor: remove material from absorb_ponter_test, container_test, lookup_boundary_test, page_view_test, router_test, semantics_clipping_test, semantics_merge_test, shadow_test, text_test (flutter/flutter#183309) 2026-04-08 [email protected] Remove editable_text_utils cross-imports from material and cupertino … (flutter/flutter#184519) 2026-04-08 [email protected] Replace hard coded max path length with system defined one. (flutter/flutter#184697) 2026-04-08 [email protected] [Re-land] Add Support For Built-in Kotlin (flutter/flutter#184745) 2026-04-08 [email protected] Manually stop and continue LLDB breakpoints on Xcode 26.4+ (flutter/flutter#184690) 2026-04-08 [email protected] Code freeze workflow (flutter/flutter#184246) 2026-04-08 [email protected] [Dot shorthands] Migrate examples/api/lib/widgets (flutter/flutter#183965) 2026-04-08 [email protected] [cupertino.dart] Implement CupertinoMenuAnchor and CupertinoMenuItem using RawMenuAnchor (flutter/flutter#182036) 2026-04-08 [email protected] [Semantics] clarify Android header docs (flutter/flutter#183573) 2026-04-08 [email protected] [ci] mac build_test bringup false (flutter/flutter#184738) 2026-04-08 [email protected] Reland "Apply rect clipping to surface views" (flutter/flutter#184732) 2026-04-08 [email protected] Remove bringup label for resharded Windows tool_integration_tests shards (flutter/flutter#184721) 2026-04-08 [email protected] Tool: Add search and filtering to widget preview scaffold (flutter/flutter#184023) 2026-04-08 [email protected] Update localization from translation console (flutter/flutter#184742) 2026-04-07 [email protected] Revert "Add Support For Built-in Kotlin (#184227)" (flutter/flutter#184739) 2026-04-07 [email protected] Collect HCPP adoption analytics for flutter run/build apk/build appbundle (flutter/flutter#184225) 2026-04-07 [email protected] Add a github workflow for reverting PRs. (flutter/flutter#184593) 2026-04-07 [email protected] Add Support For Built-in Kotlin (flutter/flutter#184227) 2026-04-07 [email protected] Revert "Apply rect clipping to surface views (#184471)" (flutter/flutter#184728) 2026-04-07 [email protected] [Fix-forward] Added Compose plugin to Add-to-app Integration Test (flutter/flutter#184681) 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 [email protected],[email protected] 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
Part of #181513