From 38b2cfbc7213edbd7516108497a30164573cb40c Mon Sep 17 00:00:00 2001 From: Leozin777 Date: Thu, 27 Nov 2025 16:18:29 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20search=20bar=20visibl?= =?UTF-8?q?e=20property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/json_editor_flutter.dart | 9 +++++++++ 1 file changed, 9 insertions(+) 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(