From ab8c4db157600a1549b76ebd6d5048a8fea76f52 Mon Sep 17 00:00:00 2001 From: ziyadsfaxi Date: Wed, 6 Jul 2022 23:18:48 +0800 Subject: [PATCH 1/2] Add suggestions box elevation option --- CHANGELOG.md | 3 +++ lib/src/chips_input.dart | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 823f48a0..aae87e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [2.0.1] - 06-Jul-2022 +- Added Suggestions Box Elevation option + ## [2.0.0] - 16-May-2022 * Flutter 3 compatibility diff --git a/lib/src/chips_input.dart b/lib/src/chips_input.dart index 3c10a20d..74bc28e8 100644 --- a/lib/src/chips_input.dart +++ b/lib/src/chips_input.dart @@ -51,6 +51,7 @@ class ChipsInput extends StatefulWidget { this.allowChipEditing = false, this.focusNode, this.initialSuggestions, + this.suggestionsBoxElevation = 0, }) : assert(maxChips == null || initialValue.length <= maxChips), super(key: key); @@ -75,6 +76,7 @@ class ChipsInput extends StatefulWidget { final bool allowChipEditing; final FocusNode? focusNode; final List? initialSuggestions; + final double suggestionsBoxElevation; // final Color cursorColor; @@ -203,7 +205,7 @@ class ChipsInputState extends State> builder: (context, snapshot) { if (snapshot.hasData && snapshot.data!.isNotEmpty) { final suggestionsListView = Material( - elevation: 0, + elevation: widget.suggestionsBoxElevation, child: ConstrainedBox( constraints: BoxConstraints( maxHeight: suggestionBoxHeight, From 8fbddccc2609959236efffb7a1763c3dd42ff0eb Mon Sep 17 00:00:00 2001 From: ziyadsfaxi Date: Thu, 7 Jul 2022 13:20:17 +0800 Subject: [PATCH 2/2] Add box decoration to suggestions box --- .gitignore | 1 + lib/src/chips_input.dart | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index ed90a429..99ccaec4 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ pubspec.lock # Old files *.old +.vscode/settings.json diff --git a/lib/src/chips_input.dart b/lib/src/chips_input.dart index 3c10a20d..240c074c 100644 --- a/lib/src/chips_input.dart +++ b/lib/src/chips_input.dart @@ -50,7 +50,8 @@ class ChipsInput extends StatefulWidget { this.autofocus = false, this.allowChipEditing = false, this.focusNode, - this.initialSuggestions, + this.initialSuggestions, + this.suggestionsBoxDecoration = const BoxDecoration(), }) : assert(maxChips == null || initialValue.length <= maxChips), super(key: key); @@ -75,6 +76,7 @@ class ChipsInput extends StatefulWidget { final bool allowChipEditing; final FocusNode? focusNode; final List? initialSuggestions; + final BoxDecoration suggestionsBoxDecoration; // final Color cursorColor; @@ -208,19 +210,22 @@ class ChipsInputState extends State> constraints: BoxConstraints( maxHeight: suggestionBoxHeight, ), - child: ListView.builder( - shrinkWrap: true, - padding: EdgeInsets.zero, - itemCount: snapshot.data!.length, - itemBuilder: (BuildContext context, int index) { - return _suggestions != null - ? widget.suggestionBuilder( - context, - this, - _suggestions![index] as T, - ) - : Container(); - }, + child: DecoratedBox( + decoration: widget.suggestionsBoxDecoration, + child: ListView.builder( + shrinkWrap: true, + padding: EdgeInsets.zero, + itemCount: snapshot.data!.length, + itemBuilder: (BuildContext context, int index) { + return _suggestions != null + ? widget.suggestionBuilder( + context, + this, + _suggestions![index] as T, + ) + : Container(); + }, + ), ), ), );