Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/json_editor_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<JsonEditor> createState() => _JsonEditorState();
}
Expand All @@ -168,6 +174,7 @@ class _JsonEditorState extends State<JsonEditor> {
["object"].toString(): true,
if (widget.expandedObjects.isNotEmpty) ...getExpandedParents(),
};
bool _searchBarVisible = true;

Map<String, bool> getExpandedParents() {
final map = <String, bool>{};
Expand Down Expand Up @@ -391,6 +398,7 @@ class _JsonEditorState extends State<JsonEditor> {
_enableMoreOptions = widget.enableMoreOptions;
_enableKeyEdit = widget.enableKeyEdit;
_enableValueEdit = widget.enableValueEdit;
_searchBarVisible = widget.searchBarVisible;
}

@override
Expand Down Expand Up @@ -493,6 +501,7 @@ class _JsonEditorState extends State<JsonEditor> {
Text("$_results results"),
const SizedBox(width: 5),
],
if(_searchBarVisible)
_SearchField(onSearch, onSearchAction),
const SizedBox(width: 20),
InkWell(
Expand Down