scroll problem

merge-requests/828/head
mosazaid 5 years ago
parent 6a96a9cb28
commit 9598c09ea2

@ -32,13 +32,21 @@ class _InPatientListPageState extends State<InPatientListPage> {
bool isAllClinic = true; bool isAllClinic = true;
bool showBottomSheet = false; bool showBottomSheet = false;
String selectedClinicName; String selectedClinicName;
ScrollController _scrollController;
@override @override
void dispose() { void dispose() {
_searchController.dispose(); _searchController.dispose();
_scrollController.dispose();
super.dispose(); super.dispose();
} }
@override
void initState() {
_scrollController = new ScrollController();
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
@ -167,13 +175,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
: Expanded( : Expanded(
child: Container( child: Container(
margin: EdgeInsets.symmetric(horizontal: 16.0), margin: EdgeInsets.symmetric(horizontal: 16.0),
child: NotificationListener( child: NotificationListener<ScrollEndNotification>(
child: ListView.builder( child: ListView.builder(
itemCount: widget.patientSearchViewModel itemCount: widget.patientSearchViewModel
.filteredInPatientItems.length, .filteredInPatientItems.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
// physics: ScrollPhysics(), // physics: ScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
controller: _scrollController,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (!widget.isMyInPatient) if (!widget.isMyInPatient)
return PatientCard( return PatientCard(
@ -276,14 +285,19 @@ class _InPatientListPageState extends State<InPatientListPage> {
else else
return SizedBox(); return SizedBox();
}), }),
onNotification: (t) { onNotification: (notification) {
if (isAllClinic) if (t if (isAllClinic) if (notification
is ScrollUpdateNotification && is ScrollUpdateNotification &&
t.metrics.pixels >= notification.metrics.pixels >=
t.metrics.maxScrollExtent - 50) { notification.metrics.maxScrollExtent - 50) {
widget.patientSearchViewModel widget.patientSearchViewModel
.addOnFilteredList(); .addOnFilteredList();
} }
// print("scroll position scroll ${_scrollController.position.pixels}");
// if(_scrollController.position.pixels > widget.patientSearchViewModel
// .filteredInPatientItems.length / 4){
// _scrollController.jumpTo(0);
// }
return; return;
}, },
), ),

Loading…
Cancel
Save