diff --git a/lib/json_editor_flutter.dart b/lib/json_editor_flutter.dart index 5e1becd..e48dfc0 100644 --- a/lib/json_editor_flutter.dart +++ b/lib/json_editor_flutter.dart @@ -73,6 +73,7 @@ class JsonEditor extends StatefulWidget { this.searchDuration = const Duration(milliseconds: 500), this.hideEditorsMenuButton = false, this.expandedObjects = const [], + this.searchBarVisible = true, }) : assert(editors.length > 0, "editors list cannot be empty"); /// JSON string to be edited. @@ -145,6 +146,11 @@ class JsonEditor extends StatefulWidget { /// ``` final List expandedObjects; + /// Controls the visibility of the search bar in the tree editor. When `true`, + /// displays a search field that allows users to find and navigate to specific + /// keys within the JSON structure. Defaults to `true`. + final bool searchBarVisible; + @override State createState() => _JsonEditorState(); } @@ -168,6 +174,7 @@ class _JsonEditorState extends State { ["object"].toString(): true, if (widget.expandedObjects.isNotEmpty) ...getExpandedParents(), }; + bool _searchBarVisible = true; Map getExpandedParents() { final map = {}; @@ -391,6 +398,7 @@ class _JsonEditorState extends State { _enableMoreOptions = widget.enableMoreOptions; _enableKeyEdit = widget.enableKeyEdit; _enableValueEdit = widget.enableValueEdit; + _searchBarVisible = widget.searchBarVisible; } @override @@ -493,6 +501,7 @@ class _JsonEditorState extends State { Text("$_results results"), const SizedBox(width: 5), ], + if(_searchBarVisible) _SearchField(onSearch, onSearchAction), const SizedBox(width: 20), InkWell(