Is there a way to prevent a PageView from rerunning code on swipe?

Let me preface by saying the "Update Page on Swipe" is unchecked, so it shouldn't be updating.

I have 3 pages, and each of those has a listview. The listview's children are generated by a custom function which takes 2 parameters and generates a list of a data type I created.

The problem is whenever I swipe doesn't matter which way the custom function runs again. It doesn't update or change any of the children, and it doesn't reset whatever the user has written or interacted with, but it seems like rerunning the code is totally unecessary.

Is there anything I can do to prevent it? I think I can create a variable to hold if the page was already loaded once and then just skip the code if it is true, but that seems inefficient.

Edit: Whatever custom functions I have executing in components inside the listview also rerun.

Thanks in advance.

4