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

Show one circle at a time #9

Open
iamkunalpitale opened this issue Mar 24, 2020 · 1 comment
Open

Show one circle at a time #9

iamkunalpitale opened this issue Mar 24, 2020 · 1 comment

Comments

@iamkunalpitale
Copy link

How to show one circle at a time its moving too fast???
Speed make it slow??

@Zamorite
Copy link

To achieve a one-circle-at-a-time scroll behaviour, I would recommend using a custom ScrollPhysics which extends CircleFixedExtentScrollPhysics.

class CustomScrollPhysics extends CircleFixedExtentScrollPhysics {
  const CustomScrollPhysics ({ScrollPhysics parent}) : super(parent: parent);

  @override
  double get minFlingVelocity => double.infinity;

  @override
  double get maxFlingVelocity => double.infinity;

  @override
  double get minFlingDistance => double.infinity;

  @override
  CustomScrollPhysics applyTo(ScrollPhysics ancestor) {
    return CustomScrollPhysics (parent: buildParent(ancestor));
  }
}

The CustomScrollPhysics can then be passed to the CircleListScrollView as shown below.

CircleListScrollView(
    physics: CustomScrollPhysics(),
    axis: Axis.horizontal,
    itemExtent: 175,
    children: List.generate(
        5,
        (int i) => Center(
            // feel free to design each item as you wish here...
            child: Container(
                 width: 175,
                 height: 175,
                 color: Colors.blue,
            ),
         ),
     ),
     radius: MediaQuery.of(context).size.width * .65,
),

Source: StackOverflow

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

No branches or pull requests

2 participants