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