[FR] EditorState could be listenable
Description
Right now, you have to use setState to force an update when making a change to EditorState.
It would be better if you could listen to EditorState and react to changes. EditorState could extend ChangeNotifier.
Impact
It would be more intuitive and act more like common Flutter APIs like TextEditingController
Additional Context
I use flutter_hooks for ephemeral state management, so it's not straightforward to force update state with setstate like is achieved here:
return MobileToolbarItemMenuBtn(
icon: AFMobileIcon(
afMobileIcons: currentDecoration.icon,
color: MobileToolbarTheme.of(context).iconColor,
),
label: Text(currentDecoration.label),
isSelected: isSelected,
onPressed: () {
setState(() {
widget.editorState.toggleAttribute(currentDecoration.name);
});
},
);
I can't see a reason why you couldn't use eg. the Selection or Attribute toggle Notifiers for your use-case.
editorState.toggledStyleNotifier;
editorState.selectionNotifier;
You can also subscribe to the transactions applied to the EditorState through editorState.transactionStream.
Are there any cases we have missed or you think would require more coverage?