[cupertino_ui] Create util files. Remove widgets import in adaptive_text_selection_toolbar_test.dart and text_selection_test.dart#12023
Conversation
There was a problem hiding this comment.
Code Review
This pull request resolves cross-import issues by removing @Skip annotations from adaptive_text_selection_toolbar_test.dart and text_selection_test.dart, and introducing local test utilities clipboard_utils.dart and text_selection_toolbar_utils.dart. Feedback is provided regarding a potential runtime TypeError in MockClipboard when casting clipboardData to Map<String, dynamic>? instead of Map<dynamic, dynamic>?.
| if (hasStringsThrows) { | ||
| throw Exception(); | ||
| } | ||
| final clipboardDataMap = clipboardData as Map<String, dynamic>?; |
There was a problem hiding this comment.
Casting clipboardData directly to Map<String, dynamic>? can throw a TypeError at runtime. When platform channel methods like Clipboard.setData are invoked, the arguments are decoded as Map<Object?, Object?> (or Map<dynamic, dynamic>) by the standard message codec. In Dart, a Map<Object?, Object?> cannot be cast to Map<String, dynamic> using as and will result in a TypeError. Using Map<dynamic, dynamic>? is safer and avoids this issue.
| final clipboardDataMap = clipboardData as Map<String, dynamic>?; | |
| final clipboardDataMap = clipboardData as Map<dynamic, dynamic>?; |
2cc00fd to
0528f30
Compare
Part of flutter/flutter#182636 and flutter/flutter#188395
This PR:
widgets/clipboard_utils.dartandwidgets/text_selection_toolbar_utils.dart.clipboard_utils.dartandtext_selection_toolbar_utils.darttest/folder.This is to port changes in flutter/flutter#184278
Pre-Review Checklist
[shared_preferences]///).