Skip to content

Commit f0aeeca

Browse files
feat: add support for item position notifier (xsahil03x#19)
* feat: add support for item position notifier Signed-off-by: Sahil Kumar <[email protected]> * Update lib/src/widget/positions_notifier/indexed_key.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix updateScheduled flag Signed-off-by: Sahil Kumar <[email protected]> * chore: update CHANGELOG.md Signed-off-by: Sahil Kumar <[email protected]> * Update lib/src/widget/positions_notifier/item_position.dart --------- Signed-off-by: Sahil Kumar <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5e3cb4e commit f0aeeca

9 files changed

+657
-25
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Upcoming
22

33
- Introduced `PagingWidgetBuilder` an abstract paging builder that can be used to build custom paging widgets such as Grid, List, or any other custom paging widget.
4+
- Added `ItemPositionsNotifier` for tracking item positions in scrollable lists.
45

56
## 0.2.0
67

lib/src/load_state.freezed.dart

+24-4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class _$LoadStateCopyWithImpl<$Res, $Val extends LoadState>
7777
final $Val _value;
7878
// ignore: unused_field
7979
final $Res Function($Val) _then;
80+
81+
/// Create a copy of LoadState
82+
/// with the given fields replaced by the non-null parameter values.
8083
}
8184

8285
/// @nodoc
@@ -96,6 +99,8 @@ class __$$NotLoadingImplCopyWithImpl<$Res>
9699
_$NotLoadingImpl _value, $Res Function(_$NotLoadingImpl) _then)
97100
: super(_value, _then);
98101

102+
/// Create a copy of LoadState
103+
/// with the given fields replaced by the non-null parameter values.
99104
@pragma('vm:prefer-inline')
100105
@override
101106
$Res call({
@@ -135,7 +140,9 @@ class _$NotLoadingImpl implements NotLoading {
135140
@override
136141
int get hashCode => Object.hash(runtimeType, endOfPaginationReached);
137142

138-
@JsonKey(ignore: true)
143+
/// Create a copy of LoadState
144+
/// with the given fields replaced by the non-null parameter values.
145+
@JsonKey(includeFromJson: false, includeToJson: false)
139146
@override
140147
@pragma('vm:prefer-inline')
141148
_$$NotLoadingImplCopyWith<_$NotLoadingImpl> get copyWith =>
@@ -215,7 +222,10 @@ abstract class NotLoading implements LoadState {
215222
_$NotLoadingImpl;
216223

217224
bool get endOfPaginationReached;
218-
@JsonKey(ignore: true)
225+
226+
/// Create a copy of LoadState
227+
/// with the given fields replaced by the non-null parameter values.
228+
@JsonKey(includeFromJson: false, includeToJson: false)
219229
_$$NotLoadingImplCopyWith<_$NotLoadingImpl> get copyWith =>
220230
throw _privateConstructorUsedError;
221231
}
@@ -234,6 +244,9 @@ class __$$LoadingImplCopyWithImpl<$Res>
234244
__$$LoadingImplCopyWithImpl(
235245
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
236246
: super(_value, _then);
247+
248+
/// Create a copy of LoadState
249+
/// with the given fields replaced by the non-null parameter values.
237250
}
238251

239252
/// @nodoc
@@ -345,6 +358,8 @@ class __$$ErrorImplCopyWithImpl<$Res>
345358
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
346359
: super(_value, _then);
347360

361+
/// Create a copy of LoadState
362+
/// with the given fields replaced by the non-null parameter values.
348363
@pragma('vm:prefer-inline')
349364
@override
350365
$Res call({
@@ -381,7 +396,9 @@ class _$ErrorImpl implements Error {
381396
int get hashCode =>
382397
Object.hash(runtimeType, const DeepCollectionEquality().hash(error));
383398

384-
@JsonKey(ignore: true)
399+
/// Create a copy of LoadState
400+
/// with the given fields replaced by the non-null parameter values.
401+
@JsonKey(includeFromJson: false, includeToJson: false)
385402
@override
386403
@pragma('vm:prefer-inline')
387404
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
@@ -460,7 +477,10 @@ abstract class Error implements LoadState {
460477
const factory Error([final Object? error]) = _$ErrorImpl;
461478

462479
Object? get error;
463-
@JsonKey(ignore: true)
480+
481+
/// Create a copy of LoadState
482+
/// with the given fields replaced by the non-null parameter values.
483+
@JsonKey(includeFromJson: false, includeToJson: false)
464484
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
465485
throw _privateConstructorUsedError;
466486
}

lib/src/paging_source.freezed.dart

+54-13
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ mixin _$LoadParams<Key> {
7474
}) =>
7575
throw _privateConstructorUsedError;
7676

77-
@JsonKey(ignore: true)
77+
/// Create a copy of LoadParams
78+
/// with the given fields replaced by the non-null parameter values.
79+
@JsonKey(includeFromJson: false, includeToJson: false)
7880
$LoadParamsCopyWith<Key, LoadParams<Key>> get copyWith =>
7981
throw _privateConstructorUsedError;
8082
}
@@ -98,6 +100,8 @@ class _$LoadParamsCopyWithImpl<Key, $Res, $Val extends LoadParams<Key>>
98100
// ignore: unused_field
99101
final $Res Function($Val) _then;
100102

103+
/// Create a copy of LoadParams
104+
/// with the given fields replaced by the non-null parameter values.
101105
@pragma('vm:prefer-inline')
102106
@override
103107
$Res call({
@@ -131,6 +135,8 @@ class __$$RefreshImplCopyWithImpl<Key, $Res>
131135
_$RefreshImpl<Key> _value, $Res Function(_$RefreshImpl<Key>) _then)
132136
: super(_value, _then);
133137

138+
/// Create a copy of LoadParams
139+
/// with the given fields replaced by the non-null parameter values.
134140
@pragma('vm:prefer-inline')
135141
@override
136142
$Res call({
@@ -199,7 +205,9 @@ class _$RefreshImpl<Key> with DiagnosticableTreeMixin implements Refresh<Key> {
199205
int get hashCode => Object.hash(
200206
runtimeType, const DeepCollectionEquality().hash(key), loadSize);
201207

202-
@JsonKey(ignore: true)
208+
/// Create a copy of LoadParams
209+
/// with the given fields replaced by the non-null parameter values.
210+
@JsonKey(includeFromJson: false, includeToJson: false)
203211
@override
204212
@pragma('vm:prefer-inline')
205213
_$$RefreshImplCopyWith<Key, _$RefreshImpl<Key>> get copyWith =>
@@ -278,8 +286,6 @@ abstract class Refresh<Key> implements LoadParams<Key> {
278286
const factory Refresh({final Key? key, required final int loadSize}) =
279287
_$RefreshImpl<Key>;
280288

281-
@override
282-
283289
/// Key for the page to be loaded.
284290
///
285291
/// [key] can be `null` only if this [LoadParams] is [Refresh], and either
@@ -291,11 +297,15 @@ abstract class Refresh<Key> implements LoadParams<Key> {
291297
/// of the list.
292298
/// * [Append] - [LoadResultPage.nextKey] of the loaded page at the end of
293299
/// the list.
300+
@override
294301
Key? get key;
295302
@override
296303
int get loadSize;
304+
305+
/// Create a copy of LoadParams
306+
/// with the given fields replaced by the non-null parameter values.
297307
@override
298-
@JsonKey(ignore: true)
308+
@JsonKey(includeFromJson: false, includeToJson: false)
299309
_$$RefreshImplCopyWith<Key, _$RefreshImpl<Key>> get copyWith =>
300310
throw _privateConstructorUsedError;
301311
}
@@ -319,6 +329,8 @@ class __$$AppendImplCopyWithImpl<Key, $Res>
319329
_$AppendImpl<Key> _value, $Res Function(_$AppendImpl<Key>) _then)
320330
: super(_value, _then);
321331

332+
/// Create a copy of LoadParams
333+
/// with the given fields replaced by the non-null parameter values.
322334
@pragma('vm:prefer-inline')
323335
@override
324336
$Res call({
@@ -376,7 +388,9 @@ class _$AppendImpl<Key> with DiagnosticableTreeMixin implements Append<Key> {
376388
int get hashCode => Object.hash(
377389
runtimeType, const DeepCollectionEquality().hash(key), loadSize);
378390

379-
@JsonKey(ignore: true)
391+
/// Create a copy of LoadParams
392+
/// with the given fields replaced by the non-null parameter values.
393+
@JsonKey(includeFromJson: false, includeToJson: false)
380394
@override
381395
@pragma('vm:prefer-inline')
382396
_$$AppendImplCopyWith<Key, _$AppendImpl<Key>> get copyWith =>
@@ -459,8 +473,11 @@ abstract class Append<Key> implements LoadParams<Key> {
459473
Key get key;
460474
@override
461475
int get loadSize;
476+
477+
/// Create a copy of LoadParams
478+
/// with the given fields replaced by the non-null parameter values.
462479
@override
463-
@JsonKey(ignore: true)
480+
@JsonKey(includeFromJson: false, includeToJson: false)
464481
_$$AppendImplCopyWith<Key, _$AppendImpl<Key>> get copyWith =>
465482
throw _privateConstructorUsedError;
466483
}
@@ -484,6 +501,8 @@ class __$$PrependImplCopyWithImpl<Key, $Res>
484501
_$PrependImpl<Key> _value, $Res Function(_$PrependImpl<Key>) _then)
485502
: super(_value, _then);
486503

504+
/// Create a copy of LoadParams
505+
/// with the given fields replaced by the non-null parameter values.
487506
@pragma('vm:prefer-inline')
488507
@override
489508
$Res call({
@@ -541,7 +560,9 @@ class _$PrependImpl<Key> with DiagnosticableTreeMixin implements Prepend<Key> {
541560
int get hashCode => Object.hash(
542561
runtimeType, const DeepCollectionEquality().hash(key), loadSize);
543562

544-
@JsonKey(ignore: true)
563+
/// Create a copy of LoadParams
564+
/// with the given fields replaced by the non-null parameter values.
565+
@JsonKey(includeFromJson: false, includeToJson: false)
545566
@override
546567
@pragma('vm:prefer-inline')
547568
_$$PrependImplCopyWith<Key, _$PrependImpl<Key>> get copyWith =>
@@ -624,8 +645,11 @@ abstract class Prepend<Key> implements LoadParams<Key> {
624645
Key get key;
625646
@override
626647
int get loadSize;
648+
649+
/// Create a copy of LoadParams
650+
/// with the given fields replaced by the non-null parameter values.
627651
@override
628-
@JsonKey(ignore: true)
652+
@JsonKey(includeFromJson: false, includeToJson: false)
629653
_$$PrependImplCopyWith<Key, _$PrependImpl<Key>> get copyWith =>
630654
throw _privateConstructorUsedError;
631655
}
@@ -690,6 +714,9 @@ class _$LoadResultCopyWithImpl<Key, Value, $Res,
690714
final $Val _value;
691715
// ignore: unused_field
692716
final $Res Function($Val) _then;
717+
718+
/// Create a copy of LoadResult
719+
/// with the given fields replaced by the non-null parameter values.
693720
}
694721

695722
/// @nodoc
@@ -710,6 +737,8 @@ class __$$LoadResultPageImplCopyWithImpl<Key, Value, $Res>
710737
$Res Function(_$LoadResultPageImpl<Key, Value>) _then)
711738
: super(_value, _then);
712739

740+
/// Create a copy of LoadResult
741+
/// with the given fields replaced by the non-null parameter values.
713742
@pragma('vm:prefer-inline')
714743
@override
715744
$Res call({
@@ -796,7 +825,9 @@ class _$LoadResultPageImpl<Key, Value>
796825
const DeepCollectionEquality().hash(prevKey),
797826
const DeepCollectionEquality().hash(nextKey));
798827

799-
@JsonKey(ignore: true)
828+
/// Create a copy of LoadResult
829+
/// with the given fields replaced by the non-null parameter values.
830+
@JsonKey(includeFromJson: false, includeToJson: false)
800831
@override
801832
@pragma('vm:prefer-inline')
802833
_$$LoadResultPageImplCopyWith<Key, Value, _$LoadResultPageImpl<Key, Value>>
@@ -883,7 +914,10 @@ abstract class LoadResultPage<Key, Value> implements LoadResult<Key, Value> {
883914
/// [Key] for next page if more items can be loaded in that direction,
884915
/// `null` otherwise.
885916
Key? get nextKey;
886-
@JsonKey(ignore: true)
917+
918+
/// Create a copy of LoadResult
919+
/// with the given fields replaced by the non-null parameter values.
920+
@JsonKey(includeFromJson: false, includeToJson: false)
887921
_$$LoadResultPageImplCopyWith<Key, Value, _$LoadResultPageImpl<Key, Value>>
888922
get copyWith => throw _privateConstructorUsedError;
889923
}
@@ -907,6 +941,8 @@ class __$$LoadResultErrorImplCopyWithImpl<Key, Value, $Res>
907941
$Res Function(_$LoadResultErrorImpl<Key, Value>) _then)
908942
: super(_value, _then);
909943

944+
/// Create a copy of LoadResult
945+
/// with the given fields replaced by the non-null parameter values.
910946
@pragma('vm:prefer-inline')
911947
@override
912948
$Res call({
@@ -953,7 +989,9 @@ class _$LoadResultErrorImpl<Key, Value>
953989
int get hashCode =>
954990
Object.hash(runtimeType, const DeepCollectionEquality().hash(error));
955991

956-
@JsonKey(ignore: true)
992+
/// Create a copy of LoadResult
993+
/// with the given fields replaced by the non-null parameter values.
994+
@JsonKey(includeFromJson: false, includeToJson: false)
957995
@override
958996
@pragma('vm:prefer-inline')
959997
_$$LoadResultErrorImplCopyWith<Key, Value, _$LoadResultErrorImpl<Key, Value>>
@@ -1029,7 +1067,10 @@ abstract class LoadResultError<Key, Value> implements LoadResult<Key, Value> {
10291067
_$LoadResultErrorImpl<Key, Value>;
10301068

10311069
Object? get error;
1032-
@JsonKey(ignore: true)
1070+
1071+
/// Create a copy of LoadResult
1072+
/// with the given fields replaced by the non-null parameter values.
1073+
@JsonKey(includeFromJson: false, includeToJson: false)
10331074
_$$LoadResultErrorImplCopyWith<Key, Value, _$LoadResultErrorImpl<Key, Value>>
10341075
get copyWith => throw _privateConstructorUsedError;
10351076
}

lib/src/paging_state.freezed.dart

+24-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ mixin _$PagingState<Key, Value> {
2929
/// Load state of the next page.
3030
LoadState get appendLoadState => throw _privateConstructorUsedError;
3131

32-
@JsonKey(ignore: true)
32+
/// Create a copy of PagingState
33+
/// with the given fields replaced by the non-null parameter values.
34+
@JsonKey(includeFromJson: false, includeToJson: false)
3335
$PagingStateCopyWith<Key, Value, PagingState<Key, Value>> get copyWith =>
3436
throw _privateConstructorUsedError;
3537
}
@@ -62,6 +64,8 @@ class _$PagingStateCopyWithImpl<Key, Value, $Res,
6264
// ignore: unused_field
6365
final $Res Function($Val) _then;
6466

67+
/// Create a copy of PagingState
68+
/// with the given fields replaced by the non-null parameter values.
6569
@pragma('vm:prefer-inline')
6670
@override
6771
$Res call({
@@ -90,6 +94,8 @@ class _$PagingStateCopyWithImpl<Key, Value, $Res,
9094
) as $Val);
9195
}
9296

97+
/// Create a copy of PagingState
98+
/// with the given fields replaced by the non-null parameter values.
9399
@override
94100
@pragma('vm:prefer-inline')
95101
$LoadStateCopyWith<$Res> get refreshLoadState {
@@ -98,6 +104,8 @@ class _$PagingStateCopyWithImpl<Key, Value, $Res,
98104
});
99105
}
100106

107+
/// Create a copy of PagingState
108+
/// with the given fields replaced by the non-null parameter values.
101109
@override
102110
@pragma('vm:prefer-inline')
103111
$LoadStateCopyWith<$Res> get prependLoadState {
@@ -106,6 +114,8 @@ class _$PagingStateCopyWithImpl<Key, Value, $Res,
106114
});
107115
}
108116

117+
/// Create a copy of PagingState
118+
/// with the given fields replaced by the non-null parameter values.
109119
@override
110120
@pragma('vm:prefer-inline')
111121
$LoadStateCopyWith<$Res> get appendLoadState {
@@ -146,6 +156,8 @@ class __$$PagingStateImplCopyWithImpl<Key, Value, $Res>
146156
$Res Function(_$PagingStateImpl<Key, Value>) _then)
147157
: super(_value, _then);
148158

159+
/// Create a copy of PagingState
160+
/// with the given fields replaced by the non-null parameter values.
149161
@pragma('vm:prefer-inline')
150162
@override
151163
$Res call({
@@ -231,7 +243,9 @@ class _$PagingStateImpl<Key, Value> implements _PagingState<Key, Value> {
231243
prependLoadState,
232244
appendLoadState);
233245

234-
@JsonKey(ignore: true)
246+
/// Create a copy of PagingState
247+
/// with the given fields replaced by the non-null parameter values.
248+
@JsonKey(includeFromJson: false, includeToJson: false)
235249
@override
236250
@pragma('vm:prefer-inline')
237251
_$$PagingStateImplCopyWith<Key, Value, _$PagingStateImpl<Key, Value>>
@@ -246,24 +260,26 @@ abstract class _PagingState<Key, Value> implements PagingState<Key, Value> {
246260
final LoadState prependLoadState,
247261
final LoadState appendLoadState}) = _$PagingStateImpl<Key, Value>;
248262

249-
@override
250-
251263
/// List with all the pages loaded so far.
252-
PagingList<LoadResultPage<Key, Value>> get pages;
253264
@override
265+
PagingList<LoadResultPage<Key, Value>> get pages;
254266

255267
/// Load state of the initial page.
256-
LoadState get refreshLoadState;
257268
@override
269+
LoadState get refreshLoadState;
258270

259271
/// Load state of the previous page.
260-
LoadState get prependLoadState;
261272
@override
273+
LoadState get prependLoadState;
262274

263275
/// Load state of the next page.
276+
@override
264277
LoadState get appendLoadState;
278+
279+
/// Create a copy of PagingState
280+
/// with the given fields replaced by the non-null parameter values.
265281
@override
266-
@JsonKey(ignore: true)
282+
@JsonKey(includeFromJson: false, includeToJson: false)
267283
_$$PagingStateImplCopyWith<Key, Value, _$PagingStateImpl<Key, Value>>
268284
get copyWith => throw _privateConstructorUsedError;
269285
}

0 commit comments

Comments
 (0)