From 9c49e20d152f057bc78da1e1bb9ba9545f37ab9f Mon Sep 17 00:00:00 2001 From: Martin Clauss Date: Sat, 3 Jun 2023 12:52:20 +0200 Subject: [PATCH] Allow to specify maxLines Fixes: #31 --- README.md | 3 ++- lib/easy_autocomplete.dart | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d03e63..e917126 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,8 @@ The above example will generate something like below preview: | suggestionBackgroundColor | `Color` | :x: | Can be used to set custom background color to suggestions list | | | debounceDuration | `Duration` | :x: | Used to set the debounce time for async data fetch | Duration(milliseconds: 400) | | suggestionBuilder | `Widget Function(String)` | :x: | Can be used to customize suggestion items | | -| progressIndicatorBuilder | `Widget` | :x: | Can be used to display custom progress idnicator | | +| progressIndicatorBuilder | `Widget` | :x: | Can be used to display custom progress indicator | | +| maxLines | `int` | :x: | Can be used to specify the number of lines of the input, default is 1 | | ## Issues & Suggestions If you encounter any issue you or want to leave a suggestion you can do it by filling an [issue](https://github.com/4inka/flutter_easy_autocomplete/issues). diff --git a/lib/easy_autocomplete.dart b/lib/easy_autocomplete.dart index 8bdf9f5..06771f5 100644 --- a/lib/easy_autocomplete.dart +++ b/lib/easy_autocomplete.dart @@ -89,12 +89,15 @@ class EasyAutocomplete extends StatefulWidget { /// Can be used to customize suggestion items final Widget Function(String data)? suggestionBuilder; - /// Can be used to display custom progress idnicator + /// Can be used to display custom progress indicator final Widget? progressIndicatorBuilder; /// Can be used to validate field value final String? Function(String?)? validator; + /// Can be used to specify the maximum number of lines + final int maxLines; + /// Creates a autocomplete widget to help you manage your suggestions const EasyAutocomplete( {this.suggestions, @@ -116,6 +119,7 @@ class EasyAutocomplete extends StatefulWidget { this.suggestionTextStyle = const TextStyle(), this.suggestionBackgroundColor, this.debounceDuration = const Duration(milliseconds: 400), + this.maxLines = 1, this.validator}) : assert(onChanged != null || controller != null, 'onChanged and controller parameters cannot be both null at the same time'), @@ -269,7 +273,8 @@ class _EasyAutocompleteState extends State { onEditingComplete: () => closeOverlay(), validator: widget.validator != null ? (value) => widget.validator!(value) - : null // (value) {} + : null, // (value) {} + maxLines: widget.maxLines, ) ])); }