fujidaiti / exprollable_page_view

Yet another PageView widget that expands its viewport as it scrolls. Exprollable is a coined word combining the words expandable and scrollable.
https://pub.dev/packages/exprollable_page_view
MIT License
74 stars 5 forks source link

Add a factory constructor for customizing snap behavior #21

Closed fujidaiti closed 1 year ago

fujidaiti commented 1 year ago

If we want to add an additional snap position of the viewport offset, we would typically write code as follows, but it's a bit verbose.

const peekOffset = ViewportOffset.fractional(0.5);
controller = ExprollablePageController(
  initialViewportOffset: peekOffset,
  maxViewportOffset: peekOffset,
  snapViewportOffsets: [
    ViewportOffset.expanded,
    ViewportOffset.shrunk,
    peekOffset,
  ],
);

It would be nice to have a factory constructor of ExprollablePageController for simplicity like:

const peekOffset = ViewportOffset.fractional(0.5);
controller = ExprollablePageController.withAdditionalSnapOffsets(
  initialViewportOffset: peekOffset,
  additionalSnapViewportOffsets: [ peekOffset ],
);
fujidaiti commented 1 year ago

Close this issue as it has been implemented and will be included in the next release.