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

feat:exposure ERScrollBehaviorBuilder to add custom scroll behavior #614

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

laiiihz
Copy link
Contributor

@laiiihz laiiihz commented Aug 31, 2022

since flutter 3.3 landed on stable , flutter add a new pointer device (trackpad).
this PR exposure a api which can define a custom scroll behavior.

example:

class CustomScrollBehavior extends ScrollBehavior {
  final ScrollPhysics? _physics;

  const CustomScrollBehavior([this._physics]);

  @override
  ScrollPhysics getScrollPhysics(BuildContext context) {
    return _physics ?? super.getScrollPhysics(context);
  }

  @override
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return child;
  }

  @override
  Set<PointerDeviceKind> get dragDevices => <PointerDeviceKind>{
        PointerDeviceKind.touch,
        PointerDeviceKind.stylus,
        PointerDeviceKind.invertedStylus,
        PointerDeviceKind.mouse,
        PointerDeviceKind.unknown,
        // add a trackpad
        PointerDeviceKind.trackpad,
      };
}
      EasyRefresh(
        scrollBehaviorBuilder: (physics) {
          return CustomScrollBehavior(physics);
        },
        onRefresh: () async {},
        child: ListView.builder(
          itemBuilder: (context, index) {
            return const SkeletonItem();
          },
          itemCount: 8,
        ),
      )

@xuelongqy
Copy link
Owner

Thanks, this looks great.

@xuelongqy xuelongqy merged commit 9e5b8a9 into xuelongqy:v3 Nov 17, 2022
xuelongqy added a commit that referenced this pull request Nov 17, 2022
…tScrollBehaviorBuilder]. Thanks laiiihz for (#614).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants