MarkDownEditor constructor

MarkDownEditor({
  1. TextEditingController? controller,
  2. bool selectable = true,
})

Create a MarkDownEditor using a passed controller or create one if null.

selectable is used to determine if the preview will be selectable or not and default to true.

Initializes the widgets MrkdownEditingField, MarkdownEditorIcons and MarkdownPreview passing the controller or its text and all other necessary parameters.

Implementation

MarkDownEditor({
  TextEditingController? controller,
  this.selectable = true,
}) : _controller = controller ?? TextEditingController() {
  _field = MrkdownEditingField(
    controller: _controller,
    key: UniqueKey(),
    onChange: _setState,
  );
  _icons = MarkdownEditorIcons(
    controller: _controller,
    key: UniqueKey(),
    afterEditing: _setState,
  );
  _preview = StatefulBuilder(
    builder: (context, setState) {
      _setStateFuntion = setState;
      return MarkdownPreview(
        text: _controller.text,
        selectable: selectable,
        key: UniqueKey(),
      );
    },
  );
}