searchBar method
Implementation
Widget searchBar() {
return Stack(
children: <Widget>[
TextField(
controller: txtSearch,
decoration: const InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 32, vertical: 12)),
autofocus: true,
onChanged: (value) {
_updateShownIndexes(value);
setState(() {});
},
keyboardType: widget.keyboardType,
),
const Positioned(
left: 0,
top: 0,
bottom: 0,
child: Center(
child: Icon(
Icons.search,
size: 24,
),
),
),
txtSearch.text.isNotEmpty
? Positioned(
right: 0,
top: 0,
bottom: 0,
child: Center(
child: InkWell(
onTap: () {
_updateShownIndexes('');
setState(() {
txtSearch.text = '';
});
},
borderRadius: const BorderRadius.all(Radius.circular(32)),
child: const SizedBox(
width: 32,
height: 32,
child: Center(
child: Icon(
Icons.close,
size: 24,
),
),
),
),
),
)
: Container(),
],
);
}