OffsetPageScrollPosition class final
Represents an offset-based scroll position, commonly used for
index-based pagination (e.g., SQL LIMIT/OFFSET, list slicing,
sequential pagination).
This model is complementary to cursor-based pagination and is useful when:
- items are addressable by numeric index
- consistent ordering is guaranteed
- simple “skip N items” semantics are needed
An offset of -1 indicates the initial position, meaning no scroll
has yet occurred.
Usage Example
// Initial position
final pos = OffsetScrollPosition.initial();
// Advance by 20 items
final next = pos.advanceBy(20);
// Directly construct offset 40
final at40 = OffsetScrollPosition.of(40);
Design Notes
- Offsets must always be non-negative when created via of.
- The initial offset is internally represented as -1.
- Increasing the offset is done via advanceBy, which returns a new instance.
- Implements PageScrollPosition for interoperability with keyset pagination.
See Also
- Implemented types
Constructors
- OffsetPageScrollPosition(int _offset)
-
Represents an offset-based scroll position, commonly used for
index-based pagination (e.g., SQL
LIMIT/OFFSET, list slicing, sequential pagination).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
advanceBy(
int advance) → OffsetPageScrollPosition -
Advances the current offset by the given
advanceamount. -
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString.override -
getOffset(
) → int - Returns the current offset value.
-
isInitial(
) → bool -
Returns
trueif this scroll position represents the initial position of the collection or dataset.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- INITIAL → OffsetPageScrollPosition
-
The singleton instance representing the initial offset.
final
Static Methods
-
initial(
) → OffsetPageScrollPosition - Returns the initial OffsetPageScrollPosition.
-
of(
int offset) → OffsetPageScrollPosition -
Creates a new OffsetPageScrollPosition with the given positive
offset.