I am a newbie at flutter and now I am trying to implement a search delegate bar according to what I need to finish a restaurant app. The default search delegate from Flutter's Search Support (The Boring Flutter Development Show, Ep. 10) is not flexible enough because my "shopping cart" is a Scrollable BottomSheet and when I tap on search icon my search delegate take the lead I added my cart on the page expecting the scrollabe Bottomsheet take the entire screen when scrolling that but the sheet can't scroll over the search delegate appBar. Stucked on this since 4 days, I thinking to implement the hole search delegate to access the build(BuildContext context) to put a Stack over there but I don't how to implement it from scratch (only know the flutter search from Flutter's Search Support (The Boring Flutter Development Show, Ep. 10) ). If you have other way to solve my issue thanks. These are images: search bar and the sheet at its initial position initial position
search stucked appbar search delegate don't allow the sheet to sroll over
what I need the sheet
this is the code I have rigth now for the search delagate:
@override
List<Widget> buildActions(BuildContext context) {
// TODO: implement buildActions
return [
IconButton(
icon: Icon(Icons.clear),
onPressed:(){
query = "";
}
)
];
}
@override
Widget buildLeading(BuildContext context) {
// TODO: implement buildLeading
return IconButton(icon: AnimatedIcon(
icon:AnimatedIcons.menu_arrow,
progress: transitionAnimation,
),
onPressed:(){
close(context,null);
}
);
}
@override
Widget buildResults(BuildContext context) {
// TODO: implement buildResults
final suggestionList =query.isEmpty?food_recent:data.where((p)=> p.toString().contains(query)).toList();
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Stack(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// SizedBox(height: 8),
AspectRatio(
aspectRatio: 0.8,
child: Opacity(
opacity: 1,
child:ListView.builder(
//padding: EdgeInsets.only(right: 32, top: 128),
//controller: scrollController,
itemCount: suggestionList?.length ?? 0, //20,
itemBuilder: (context, index) {
//Event event = events[index % 3];
Produit event = suggestionList[index];
return MyEventItemProduct(
event: event,
percentageCompleted:0.15,
);
},
),
),
)
//Tabs(),
//SizedBox(height: 8),
//SlidingCardsView(),
],
),
ScrollableExhibitionSheet(),//use this or ScrollableExhibitionSheet
],
);
});
}
@override
Widget buildSuggestions(BuildContext context) {
// TODO: implement buildSuggestions
//new Text(suggestionList[index]["colis"]["libelle_coli"]),
final suggestionList =query.isEmpty?food_recent:data.where((p)=> p.toString().contains(query)).toList();
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Stack(
overflow: Overflow.clip,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// SizedBox(height: 8),
AspectRatio(
aspectRatio: 0.8,
child: Opacity(
opacity: 1,
child:ListView.builder(
//padding: EdgeInsets.only(right: 32, top: 128),
//controller: scrollController,
itemCount: suggestionList?.length ?? 0, //20,
itemBuilder: (context, index) {
//Event event = events[index % 3];
Produit event = suggestionList[index];
return MyEventItemProduct(
event: event,
percentageCompleted:0.15,
);
},
),
),
)
//Tabs(),
//SizedBox(height: 8),
//SlidingCardsView(),
],
),
ScrollableExhibitionSheet(),//use this or ScrollableExhibitionSheet
],
);
});
}
and rigth because I don't know how to solve my problem I decide to implement it from srcatch to have the build method widget. this is what I am trying to do but I don't know how to implement the 10 other methods asked to made it work like the default appbar.
class Searchp extends StatelessWidget implements SearchDelegate <Produit>{
@override
String query;
@override
ThemeData appBarTheme(BuildContext context) {
// TODO: implement appBarTheme
return null;
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return null;
}
@override
List<Widget> buildActions(BuildContext context) {
// TODO: implement buildActions
return null;
}
@override
Widget buildLeading(BuildContext context) {
// TODO: implement buildLeading
return null;
}
@override
Widget buildResults(BuildContext context) {
// TODO: implement buildResults
return null;
}
@override
Widget buildSuggestions(BuildContext context) {
// TODO: implement buildSuggestions
return null;
}
@override
void close(BuildContext context, Produit result) {
// TODO: implement close
}
@override
// TODO: implement keyboardType
TextInputType get keyboardType => null;
@override
// TODO: implement searchFieldLabel
String get searchFieldLabel => null;
@override
void showResults(BuildContext context) {
// TODO: implement showResults
}
@override
void showSuggestions(BuildContext context) {
// TODO: implement showSuggestions
}
@override
// TODO: implement textInputAction
TextInputAction get textInputAction => null;
@override
// TODO: implement transitionAnimation
Animation<double> get transitionAnimation => null;
}
finally extends from StatelessWidget was not needed. override the _SearchPageState class from src/material/search.dart solved my problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.