-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
I have FutureBuilder>>ListView widgets Inside @OverRide buildResults(BuildContext context) method. I navigate to a new screen on list view item tap. but when i pop from the new screen the future is called again. Also i have pagination in the main list view, so when the user tap on item 100 for ex. after popping from the new screen, the main listview it will rebuild from the beginning
class DataSearch extends SearchDelegate<String>{
@override
List<Widget> buildActions(BuildContext context) {
return [
IconButton(
icon: Icon(Icons.clear),
onPressed: () {
query = '';
})
];
}
@override
ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context);
return theme.copyWith(
inputDecorationTheme: InputDecorationTheme(
hintStyle: TextStyle(color: theme.primaryTextTheme.title.color)),
primaryColor: theme.primaryColor,
primaryIconTheme: theme.primaryIconTheme,
primaryColorBrightness: theme.primaryColorBrightness,
primaryTextTheme: theme.primaryTextTheme,
textTheme: theme.textTheme.copyWith(
title: theme.textTheme.title
.copyWith(color: theme.primaryTextTheme.title.color)));
}
@override
Widget buildLeading(BuildContext context) {
return IconButton(
icon: AnimatedIcon(
icon: AnimatedIcons.menu_arrow, progress: transitionAnimation),
onPressed: () {
close(context, null);
});
}
@override
Widget buildResults(BuildContext context) {
SearchProvider searchProvider =
Provider.of<SearchProvider>(context, listen: false);
return query.isEmpty == true ? Container() : FutureBuilder(
future: searchProvider.fetchData(query),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(
child: SpinKitHourGlass(
color: Colors.greenAccent,
));
break;
default:
if (snapshot.hasError) {
return Center(child: Text("Error: ${snapshot.error}"));
} else {
return Consumer<SearchProvider>(
builder: (context, provider, child) => ImageList(
models: snapshot.data,
isSearch: true,
),
);
}
}
});
}
@override
Widget buildSuggestions(BuildContext context) {
return Container();
}
}
gopalkriagg, SalehHub, calibresync, JigneshWorld, nioncode and 18 more
Metadata
Metadata
Assignees
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team