Skip to content

Commit

Permalink
Analyzer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmc committed Aug 4, 2021
1 parent db6f34a commit cfc4a77
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/services/clipboard.dart
Expand Up @@ -66,7 +66,7 @@ class Clipboard {
/// See also:
/// * [The iOS hasStrings method](https://developer.apple.com/documentation/uikit/uipasteboard/1829416-hasstrings?language=objc).
static Future<bool> hasStrings() async {
final Map<String, dynamic> result = await SystemChannels.platform.invokeMethod(
final Map<String, dynamic>? result = await SystemChannels.platform.invokeMethod(
'Clipboard.hasStrings',
Clipboard.kTextPlain,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/widgets/text_selection.dart
Expand Up @@ -1662,7 +1662,7 @@ class ClipboardStatusNotifier extends ValueNotifier<ClipboardStatus> with Widget
late final bool hasStrings;
try {
hasStrings = await Clipboard.hasStrings();
} catch (stacktrace, e) {
} catch (stacktrace) {
// In the case of an error from the Clipboard API, set the value to
// unknown so that it will try to update again later.
if (_disposed || value == ClipboardStatus.unknown) {
Expand Down
5 changes: 3 additions & 2 deletions packages/flutter/test/widgets/text_selection_test.dart
Expand Up @@ -26,8 +26,9 @@ class MockClipboard {
case 'Clipboard.hasStrings':
if (hasStringsThrows)
throw Exception();
final String? text = _clipboardData?['text'];
return <String, bool>{'value': text != null && text.length > 0};
final Map<String, dynamic>? clipboardDataMap = _clipboardData as Map<String, dynamic>?;
final String? text = clipboardDataMap?['text'] as String?;
return <String, bool>{'value': text != null && text.isNotEmpty};
case 'Clipboard.setData':
_clipboardData = methodCall.arguments;
break;
Expand Down

0 comments on commit cfc4a77

Please sign in to comment.