didUpdateWidget method
zmtzawqlp
Implementation
@override
/// zmtzawqlp
void didUpdateWidget(_EditableText oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.controller != oldWidget.controller) {
oldWidget.controller.removeListener(_didChangeTextEditingValue);
widget.controller.addListener(_didChangeTextEditingValue);
_updateRemoteEditingValueIfNeeded();
}
if (_selectionOverlay != null &&
(widget.contextMenuBuilder != oldWidget.contextMenuBuilder ||
widget.selectionControls != oldWidget.selectionControls ||
widget.onSelectionHandleTapped !=
oldWidget.onSelectionHandleTapped ||
widget.dragStartBehavior != oldWidget.dragStartBehavior ||
widget.magnifierConfiguration !=
oldWidget.magnifierConfiguration)) {
final bool shouldShowToolbar = _selectionOverlay!.toolbarIsVisible;
final bool shouldShowHandles = _selectionOverlay!.handlesVisible;
_selectionOverlay!.dispose();
_selectionOverlay = _createSelectionOverlay();
if (shouldShowToolbar || shouldShowHandles) {
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
if (shouldShowToolbar) {
_selectionOverlay!.showToolbar();
}
if (shouldShowHandles) {
_selectionOverlay!.showHandles();
}
});
}
} else if (widget.controller.selection != oldWidget.controller.selection) {
_selectionOverlay?.update(_value);
}
_selectionOverlay?.handlesVisible = widget.showSelectionHandles;
if (widget.autofillClient != oldWidget.autofillClient) {
_currentAutofillScope
?.unregister(oldWidget.autofillClient?.autofillId ?? autofillId);
_currentAutofillScope?.register(_effectiveAutofillClient);
}
if (widget.focusNode != oldWidget.focusNode) {
oldWidget.focusNode.removeListener(_handleFocusChanged);
widget.focusNode.addListener(_handleFocusChanged);
updateKeepAlive();
}
if (!_shouldCreateInputConnection) {
_closeInputConnectionIfNeeded();
} else if (oldWidget.readOnly && _hasFocus) {
// _openInputConnection must be called after layout information is available.
// See https://github.com/flutter/flutter/issues/126312
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
_openInputConnection();
}, debugLabel: 'EditableText.openInputConnection');
}
if (kIsWeb && _hasInputConnection) {
if (oldWidget.readOnly != widget.readOnly) {
_textInputConnection!
.updateConfig(_effectiveAutofillClient.textInputConfiguration);
}
}
if (_hasInputConnection) {
if (oldWidget.obscureText != widget.obscureText) {
_textInputConnection!
.updateConfig(_effectiveAutofillClient.textInputConfiguration);
}
}
if (widget.style != oldWidget.style) {
// The _textInputConnection will pick up the new style when it attaches in
// _openInputConnection.
_style = MediaQuery.boldTextOf(context)
? widget.style.merge(const TextStyle(fontWeight: FontWeight.bold))
: widget.style;
if (_hasInputConnection) {
_textInputConnection!.setStyle(
fontFamily: _style.fontFamily,
fontSize: _style.fontSize,
fontWeight: _style.fontWeight,
textDirection: _textDirection,
textAlign: widget.textAlign,
);
}
}
if (widget.showCursor != oldWidget.showCursor) {
_startOrStopCursorTimerIfNeeded();
}
final bool canPaste =
widget.selectionControls is TextSelectionHandleControls
? pasteEnabled
: widget.selectionControls?.canPaste(this) ?? false;
if (widget.selectionEnabled && pasteEnabled && canPaste) {
clipboardStatus.update();
}
}