Skip to content

Allow accessing state (readonly) during lifecycle callbacks #4362

@holzgeist

Description

@holzgeist

Is your feature request related to a problem? Please describe.
Related to #4352. Use case: cleanup timers etc stored in state during onDispose

Describe the solution you'd like
I'd like a readonly view of state during lifecycle callbacks. Especially onDispose, but I guess onCancel and onResume would be interesting too for others.

I can think of two ways to implement this:

  • allow readonly access to state during those callbacks (but prevent writes)
  • pass current state as part of onDispose callback

Describe alternatives you've considered
The examples usually use final variables in build and access them during cleanup. In my scenario, the value can change over time, so this approach doesn't work.
All other ideas that I came up with are hacky at best and I didn't even verify if they would work (static variables, member variables that duplicate the relevant values of state etc)

Additional context
N/A

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions