diff --git a/example/lib/main.dart b/example/lib/main.dart index 08bdf8b..ef8cabc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -252,6 +252,31 @@ class _MyHomePageState extends State { ), ], ), + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 12), + child: const Text( + "Search:", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), + Expanded( + child: GroupsField( + isScrollable: false, + textFieldDecoration: InputDecoration( + hintText: 'Some hint?', + ), + groups: [ + simpleGroup, + tagsGroup, + ], + ), + ), + ], + ), ], ), ), diff --git a/lib/groups_field.dart b/lib/groups_field.dart index b65ed53..bef0b7d 100644 --- a/lib/groups_field.dart +++ b/lib/groups_field.dart @@ -53,6 +53,8 @@ class GroupsField extends StatefulWidget { final LogicalKeyboardKey keyForTriggerRemoveField; final Function? onSubmitted; + final InputDecoration? textFieldDecoration; + const GroupsField({ required this.groups, super.key, @@ -68,6 +70,7 @@ class GroupsField extends StatefulWidget { this.onSomeFieldOfGroupSelected, this.keyForTriggerRemoveField = LogicalKeyboardKey.backspace, this.onSubmitted, + this.textFieldDecoration, }); @override @@ -364,6 +367,7 @@ class _GroupsFieldState extends State { lastFieldSize: lastFieldSize, onSubmitted: widget.onSubmitted, textFieldFocusNode: _textFieldFocusNode, + inputDecoration: widget.textFieldDecoration, ) : textFieldBuilder( context, diff --git a/lib/ui/default_text_field.dart b/lib/ui/default_text_field.dart index 125d2c7..5fceeed 100644 --- a/lib/ui/default_text_field.dart +++ b/lib/ui/default_text_field.dart @@ -9,6 +9,8 @@ class DefaultTextField extends StatelessWidget { final FocusNode? textFieldFocusNode; final TextEditingController? controller; + final InputDecoration? inputDecoration; + const DefaultTextField({ super.key, required this.lastFieldSize, @@ -16,23 +18,28 @@ class DefaultTextField extends StatelessWidget { this.onSubmitted, this.textFieldFocusNode, this.controller, + this.inputDecoration, }); @override Widget build(BuildContext context) { final callback = onSubmitted; + final contentPadding = EdgeInsets.only( + top: cursorPosition.dy, + left: cursorPosition.dx, + bottom: cursorPosition.dy == 0 ? 0 : lastFieldSize.height / 2, + ); + + final decorator = inputDecoration; + return TextField( focusNode: textFieldFocusNode, onSubmitted: (_) => callback == null ? null : callback(), controller: controller, - decoration: InputDecoration( - contentPadding: EdgeInsets.only( - top: cursorPosition.dy, - left: cursorPosition.dx, - bottom: cursorPosition.dy == 0 ? 0 : lastFieldSize.height / 2, - ), - ), + decoration: decorator == null + ? InputDecoration(contentPadding: contentPadding) + : decorator.copyWith(contentPadding: contentPadding, isDense: false), ); } }