Fix text alignment of searchbar
This commit is contained in:
@@ -109,6 +109,7 @@ class _MihSearchBarState extends State<MihSearchBar> {
|
|||||||
color: widget.fillColor,
|
color: widget.fillColor,
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
// Keep AnimatedContainer for width/height transitions
|
// Keep AnimatedContainer for width/height transitions
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
height: widget.height ?? 50,
|
height: widget.height ?? 50,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
@@ -123,6 +124,7 @@ class _MihSearchBarState extends State<MihSearchBar> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
textAlignVertical: TextAlignVertical.center,
|
||||||
controller: widget.controller, // Assign the controller
|
controller: widget.controller, // Assign the controller
|
||||||
focusNode: widget.searchFocusNode,
|
focusNode: widget.searchFocusNode,
|
||||||
autocorrect: true,
|
autocorrect: true,
|
||||||
@@ -134,17 +136,20 @@ class _MihSearchBarState extends State<MihSearchBar> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: widget.hintColor,
|
color: widget.hintColor,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
cursorColor: widget.hintColor,
|
cursorColor: widget.hintColor,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
hintText: widget.hintText,
|
hintText: widget.hintText,
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
color: widget.hintColor,
|
color: widget.hintColor,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding:
|
contentPadding:
|
||||||
const EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0),
|
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 15.0),
|
||||||
prefixIcon: GestureDetector(
|
prefixIcon: GestureDetector(
|
||||||
onTap: widget.onPrefixIconTap,
|
onTap: widget.onPrefixIconTap,
|
||||||
child: getPrefixIcon(),
|
child: getPrefixIcon(),
|
||||||
@@ -152,12 +157,15 @@ class _MihSearchBarState extends State<MihSearchBar> {
|
|||||||
suffixIcon: Row(
|
suffixIcon: Row(
|
||||||
// Use a Row for multiple suffix icons
|
// Use a Row for multiple suffix icons
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// Optional suffix tools
|
// Optional suffix tools
|
||||||
if (widget.suffixTools != null) ...widget.suffixTools!,
|
if (widget.suffixTools != null) ...widget.suffixTools!,
|
||||||
// Clear Icon (conditionally visible)
|
// Clear Icon (conditionally visible)
|
||||||
if (_showClearIcon) // Only show if input is not empty
|
if (_showClearIcon) // Only show if input is not empty
|
||||||
IconButton(
|
IconButton(
|
||||||
|
iconSize: 35,
|
||||||
icon: Icon(Icons.clear,
|
icon: Icon(Icons.clear,
|
||||||
color: widget.hintColor), // Clear icon
|
color: widget.hintColor), // Clear icon
|
||||||
onPressed: widget.onClearIconTap ??
|
onPressed: widget.onClearIconTap ??
|
||||||
|
|||||||
Reference in New Issue
Block a user