robert-luoqing / flutter_list_view

MIT License
45 stars 17 forks source link

how to know current index visible in viewport(header) #24

Closed rahulk3sharma closed 3 months ago

robert-luoqing commented 1 year ago

You can get it by

  _stickyHeaderChanged() {
    print(
        "Sticky Header Change To: ${controller.sliverController.stickyIndex.value}");
  }

  _fetchStickHeader() async {
    await Future.delayed(const Duration(milliseconds: 100));
    print(
        "Sticky Header Change To: ${controller.sliverController.stickyIndex.value}");
  }

  @override
  void initState() {
    _loadCountry();
    controller.sliverController.stickyIndex.addListener(_stickyHeaderChanged);
    _fetchStickHeader();
    super.initState();
  }