Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when change scroll direction #53

Open
Kaon81 opened this issue Dec 14, 2023 · 1 comment
Open

Bug when change scroll direction #53

Kaon81 opened this issue Dec 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Any help/suggestions are welcome

Comments

@Kaon81
Copy link

Kaon81 commented Dec 14, 2023

Similar to #51
The problem is different behaviour when list has one element and 100 elements.

  1. One element
    I can scroll up and down during dragging

  2. 100 elements
    When I change scroll direction refresh will be hide

There is possibility to make it consistent?

@gonuit
Copy link
Owner

gonuit commented Jan 5, 2024

Hi @Kaon81 👋🏻,

Unfortunately, this is the current behavior of the built-in RefreshIndicator widget, caused by the current implementation of the underlying scroll mechanism (flutter/flutter#71075 / flutter/flutter#36158).

However, I have created a workaround that you can give a try.


How to

  1. Use the version 3.1.0-dev.1 of the custom_refresh_indicator package.
  2. Assign the newly added ClampingWithOverscrollPhysics scroll physics and provide the IndicatorController as a state parameter.

Example

A minimal working example might look like the following:

import 'package:flutter/material.dart';
import 'package:custom_refresh_indicator/custom_refresh_indicator.dart';

class RefreshList extends StatefulWidget {
  const RefreshList({
    super.key,
  });

  @override
  State<RefreshList> createState() => _RefreshListState();
}

class _RefreshListState extends State<RefreshList> {
  final _controller = IndicatorController();
  @override
  Widget build(BuildContext context) {
    return CustomMaterialIndicator(
      controller: _controller,
      onRefresh: () => Future.delayed(const Duration(seconds: 2)),
      indicatorBuilder: (context, controller) => const Icon(Icons.ac_unit, size: 30),
      child: ListView.builder(
        physics: AlwaysScrollableScrollPhysics(
          parent: ClampingWithOverscrollPhysics(state: _controller),
        ),
        itemBuilder: (context, index) => ListTile(
          title: Text('${index + 1}'),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

Demo

The source code for the demo below can be found HERE.

2024-01-05 01 30 48


Notes

  • It is still just a workaround, in most cases it works, but it may not yet be the final solution for this package.

@gonuit gonuit self-assigned this Jan 5, 2024
@gonuit gonuit added bug Something isn't working enhancement New feature or request labels Jan 5, 2024
@gonuit gonuit added the help wanted Any help/suggestions are welcome label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Any help/suggestions are welcome
Projects
None yet
Development

No branches or pull requests

2 participants