Implementation
Future<void> update() async {
if (_disposed) {
return;
}
final bool hasStrings;
try {
hasStrings = await Clipboard.hasStrings();
} catch (exception, stack) {
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'widget library',
context: ErrorDescription('while checking if the clipboard has strings'),
));
// 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) {
return;
}
value = ClipboardStatus.unknown;
return;
}
final ClipboardStatus nextStatus = hasStrings
? ClipboardStatus.pasteable
: ClipboardStatus.notPasteable;
if (_disposed) {
return;
}
value = nextStatus;
}