I want the listview to show below the search bar. It has a problem as in the example picture, it overlaps.
I use the search bar from pubdev.
This is a example image
This is a Code
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(),
resizeToAvoidBottomInset: false,
body: Stack(
fit: StackFit.expand,
children: [
Column(
children: <Widget>[
Expanded(
child: items.isNotEmpty != 0
? ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return Card(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
items[index].name!,
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 18.0,
fontFamily: 'supermarket'),
),
],
)),
);
},
)
: Center(
child: Text('Search'),
)),
],
),
buildFloatingSearchBar(),
],
),
);
}
3
Answers
Since you’re in a
Stack
widget, to make theListView
show below the SearchBar, you should first arrange the searchBar and then arrange the ListView. So, simply reverse the order of theListView()
andSearchBar
:This is if you insist on using a
Stack
. You might want to consider using aColumn()
widget instead.Looks like you don’t need Stack so just use Column
use Column instead of Stack inside Body Widget