From 58a52c9d6d1e30db649b4ed0a20c65945726d287 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 2 Apr 2022 11:37:58 +1100 Subject: [PATCH] Custom empty builder for dropdown search --- lib/api_form.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/api_form.dart b/lib/api_form.dart index b38b55b3..ff827598 100644 --- a/lib/api_form.dart +++ b/lib/api_form.dart @@ -558,6 +558,9 @@ class APIFormField { popupItemBuilder: (context, item, isSelected) { return _renderRelatedField(item, isSelected, true); }, + emptyBuilder: (context, item) { + return _renderEmptyResult(); + }, onSaved: (item) { if (item != null) { data["value"] = item["pk"]; @@ -650,9 +653,21 @@ class APIFormField { subtitle: Text("Model '${model}' rendering not supported"), ); } - } + // Construct a widget to instruct the user that no results were found + Widget _renderEmptyResult() { + return ListTile( + leading: FaIcon(FontAwesomeIcons.search), + title: Text(L10().noResults), + subtitle: Text( + L10().queryNoResults, + style: TextStyle(fontStyle: FontStyle.italic), + ), + ); + } + + // Construct a string input element Widget _constructString() {