attachConnection method
Implementation
bool attachConnection({
required int viewId,
required VoidCallback onSyncBuffer,
}) {
if (document == null) return false;
try {
connection = TextInput.attach(
client,
TextInputConfiguration(
inputType: TextInputType.multiline,
textCapitalization: TextCapitalization.sentences,
inputAction: TextInputAction.newline,
enableDeltaModel: true,
autocorrect: true,
enableSuggestions: true,
smartDashesType: SmartDashesType.disabled,
smartQuotesType: SmartQuotesType.disabled,
viewId: viewId,
),
);
if (connection == null || !connection!.attached) return false;
connection!.setEditingState(const TextEditingValue());
connection!.show();
onSyncBuffer();
connectionRetryCount = 0;
connectionRetryTimer?.cancel();
return true;
} catch (e) {
debugPrint('FluentTextInputHandler: attachConnection failed: $e');
if (connectionRetryCount < maxConnectionRetries) {
final delay = windowsRetryDelays[connectionRetryCount];
connectionRetryCount++;
connectionRetryTimer?.cancel();
connectionRetryTimer = Timer(delay, () {
attachConnection(viewId: viewId, onSyncBuffer: onSyncBuffer);
});
}
return false;
}
}