Use pull to refresh from fetching data from API with listView.Builder and StreamBuilder. When I pulldown refresh indicator appear and all is work. But I want whole of the list view to scroll down, not only showing refresh indicator. After that I can only use ListView.Builder widget, when I use listView, anything not showing in that page of scaffold.
I want like that in that photo which shown in pull_to_refresh Readme section. https://github.com/peng8350/flutter_pulltorefresh/raw/master/arts/example5.gif
newfeed.dart file
class _NewsFeedState extends State<NewsFeed> {
HomeBloc _homeBc;
RefreshController _refreshController = RefreshController();
@override
void initState() {
_homeBc = HomeBloc();
_homeBc.homePostRequest();
super.initState();
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
initialData: ResponseObj(message: MsgState.loading),
stream: _homeBc.homePostStream(),
builder: (context, snapshot) {
ResponseObj received = snapshot.data;
if (received.message == MsgState.loading) {
return Center(
child: CircularProgressIndicator(),
);
} else if (received.message == MsgState.data) {
print('=>=>=>=>=> ${received.data}');
List<HomePostData> list = received.data;
return Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SmartRefresher(
onRefresh: () {
_homeBc.homePostRequest();
},
onLoading: () {
_homeBc.loadMoreHomeRequest();
},
controller: _refreshController,
// child: ListView(
// padding: EdgeInsets.all(10),
// children: list.map((e) {
// Post(
// onTap: (){},
// image: e.image,
// postTitle: e.title,
// uploadDateTime: e.createdAt,
// postContent: e.description,
// );
// }).toList(),
// ),
child: ListView.builder(
padding: EdgeInsets.all(8.0),
physics: AlwaysScrollableScrollPhysics(),
itemCount: list.length,
itemBuilder: (context, index) {
return Post(
onTap: () {},
image: list[index].image,
postContent: list[index].description,
uploadDateTime: list[index].createdAt.split('T')[0],
postTitle: list[index].title,
);
},
),
),
),
);
} else {
return Center(
child: Text('Something Wrong'),
);
}
},
);
}
@override
void dispose() {
_homeBc.homeRqClose();
super.dispose();
}
}
home_body.dart file
class HomeBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Column(
children: [
SizedBox(height: getScreenHeightRation(10.0),),
HomeHeader(),
SizedBox(height: getScreenHeightRation(30.0),),
HomeCatergories(),
SizedBox(height: getScreenHeightRation(10.0),),
NewsFeed(),
],
),
);
}
}
question from:
https://stackoverflow.com/questions/65898383/want-whole-list-view-scroll-down-when-use-flutter-smart-refresher