ftognetto / riverpod_infinite_scroll

A plugin for Flutter's infinite_scroll_pagination that works with Riverpod.
MIT License
27 stars 23 forks source link

Make PagedState work as mixin? #15

Closed h-unterp closed 2 years ago

h-unterp commented 2 years ago

it would be nice to be able to freeze the children of PagedState, however the only way to use inheritance with a @freezed is with a mixin.

Eg:

@freezed
class MyPageState extends PagedState with _$MyPageState

Currently, this is not possible because: Screen Shot 2022-07-02 at 2 44 43 AM

Would you be ok if I make a PR to allow for this? If so, I will do it.

Then the large .copyWith can be removed from the project.

ftognetto commented 2 years ago

I think we could add a new PagedStateMixin because PagedState is necessary to use the PagedNotifier in the "easy" way (the "easy" example). If PagedState is a mixin then PagedNotifier could not use it as the state class.

If we use a mixin we could lead to an unopinionated way of using the package because the user should implement by hand all the properties of PagedState. Maybe you find a clean way of do this if you can send me an example we could work on it!