Skip to content

Instantly share code, notes, and snippets.

@ymkp
Created February 3, 2022 07:33
Show Gist options
  • Save ymkp/2f49ae882dc52c24c33be61103ce4b45 to your computer and use it in GitHub Desktop.
Save ymkp/2f49ae882dc52c24c33be61103ce4b45 to your computer and use it in GitHub Desktop.

Revisions

  1. ymkp created this gist Feb 3, 2022.
    15 changes: 15 additions & 0 deletions scroll_listener.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    NotificationListener<ScrollNotification>(
    onNotification: (ScrollNotification scrollInfo) {
    if (scrollInfo is ScrollEndNotification && // ? <-- dia dah di paling bawah, padding child juga dihitung
    scrollInfo.metrics.extentAfter == 0 && // ? <-- bener2 mentok sampai ada splash-nya
    _shopController.productState == ProductState.ok && //? <-- kondisi tambahan, cuma reload kalau lagi tidak loading
    _shopController.pageQ != -1) { //? <-- kondisi tambahan, cuma reload kalau bukan halaman/paginasi terakhir
    _shopController.getAllProductsNextPage(); //? <-- yang dilakukan untuk get next items
    return true;
    }
    return false;
    },
    child: ListView.builder(
    shrinkWrap: true,
    )
    )