Closed ana-sher closed 5 years ago
Also got problem because of you don't allow to change shrinkWrap property. Well, decided not to use this library.
Did you fond anyway to achieve this? I'm facing exactly the same situation.
Did you fond anyway to achieve this? I'm facing exactly the same situation.
I just decided to do pagination by myself. First you need to initialize your data in initState, and then it will be updated with method _getData. You also will need variables to identify loading and end of list:
bool endOfList = false;
bool loading = true; // change it when you will load your data in initState
in build:
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
itemBuilder: (context, position) {
if (position < users.length) {
return UserCard(users[position]);
} else if (position == users.length && !endOfList) {
pageData();
return _loadingCircle();
}
return null;
},
),
pageData method:
Future<List<User>> pageData() async {
if (!loading) {
await _getData((users.length / 10).round() + 1);
}
return users;
}
get Data method:
_getData(int page) async {
var filter = DataFilter(
page: page, pageSize: 10, country: country, city: city);
UserService.fetchData(filter).then((val) {
setState(() {
users.addAll(val);
loading = false;
if (val.length < 10) {
endOfList = true;
}
});
});
}
I need filters inside my page and when the filtered response came, I do the setState on data that should be reloaded and changed but nothing happened.