marcglasberg / back_button_interceptor

Flutter Package: May be used to intercept the Android back-button, as an alternative to `WillPopScope`.
BSD 2-Clause "Simplified" License
105 stars 21 forks source link

Can this be used stateless? #20

Closed sleewok closed 2 years ago

sleewok commented 2 years ago

I would like to use this with a stateless widget. Is this possible?

marcglasberg commented 2 years ago

Yes! The stateful widget example is used because the initState and the dispose methods are good places to add/remove the interceptors to coincide with some widget's lifecycle. But as long as you know when to add and remove the interceptors, these are just functions for you to call. For example, if you want an interceptor to exist all the time, you can add it in the app initialization.