Closed adrian-moisa closed 2 years ago
Found the issue. Part of it is because I forgot to add parentheses on the following subscription:
void _subscribeToUpdateListener() {
_updateListener = widget._state.refreshEditor.updateEditor$.listen(
// BEFORE
(_) => _didChangeEditingValue,
// AFTER
(_) => _didChangeEditingValue(),
);
}
The other problem for the case when users use setState in the parent is to resubscribe to the new state store. This is how Quill used to work, but it was unclear when I was doing the refactor what was its purpose. Therefore I added also comments to explain WHY?
@override
void didUpdateWidget(covariant ToggleStyleButton oldWidget) {
super.didUpdateWidget(oldWidget);
// If a new controller was generated by setState() in the parent
// we need to subscribe to the new state store.
if (oldWidget.controller != widget.controller) {
_updateListener?.cancel();
widget.controller.setStateInEditorStateReceiver(widget);
_subscribeToUpdateListener();
_isToggled = _getIsToggled(_selectionStyle.attributes);
}
}
Also toggling between styling states does not work.