update method
Check the LiveTextInputStatus and update value if needed.
Implementation
Future<void> update() async {
if (_disposed) {
return;
}
final bool isLiveTextInputEnabled;
try {
isLiveTextInputEnabled = await LiveText.isLiveTextInputAvailable();
} catch (exception, stack) {
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'widget library',
context: ErrorDescription('while checking the availability of Live Text input'),
));
// In the case of an error from the Live Text API, set the value to
// unknown so that it will try to update again later.
if (_disposed || value == LiveTextInputStatus.unknown) {
return;
}
value = LiveTextInputStatus.unknown;
return;
}
final LiveTextInputStatus nextStatus = isLiveTextInputEnabled
? LiveTextInputStatus.enabled
: LiveTextInputStatus.disabled;
if (_disposed || nextStatus == value) {
return;
}
value = nextStatus;
}