JsonEditor constructor

const JsonEditor({
  1. Key? key,
  2. required String json,
  3. required ValueChanged onChanged,
  4. Duration duration = const Duration(milliseconds: 500),
  5. bool enableMoreOptions = true,
  6. bool enableKeyEdit = true,
  7. bool enableValueEdit = true,
  8. List<Editors> editors = const [Editors.tree, Editors.text],
  9. Color? themeColor,
  10. List<Widget> actions = const [],
  11. bool enableHorizontalScroll = false,
  12. Duration searchDuration = const Duration(milliseconds: 500),
  13. bool hideEditorsMenuButton = false,
  14. List expandedObjects = const [],
})

JSON can be edited in two ways, Tree editor or text editor. You can disable either of them.

When UI editor is active, you can disable adding/deleting keys by using enableMoreOptions. Editing keys and values can also be disabled by using enableKeyEdit and enableValueEdit.

When text editor is active, it will simply ignore enableMoreOptions, enableKeyEdit and enableValueEdit.

duration is the debounce time for onChanged function. Defaults to 500 milliseconds.

editors is the supported list of editors. First element will be used as default editor. Defaults to [Editors.tree, Editors.text].

Implementation

const JsonEditor({
  super.key,
  required this.json,
  required this.onChanged,
  this.duration = const Duration(milliseconds: 500),
  this.enableMoreOptions = true,
  this.enableKeyEdit = true,
  this.enableValueEdit = true,
  this.editors = const [Editors.tree, Editors.text],
  this.themeColor,
  this.actions = const [],
  this.enableHorizontalScroll = false,
  this.searchDuration = const Duration(milliseconds: 500),
  this.hideEditorsMenuButton = false,
  this.expandedObjects = const [],
}) : assert(editors.length > 0, "editors list cannot be empty");