I have this useState
:
class RegisterFormPageWidget extends HookConsumerWidget {
const RegisterFormPageWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.watch<RegisterPageVm>(registerPageVm);
vm.page = useState(0);
But every time I navigate away with Navigator.of(context).pop()
, vm.page.value
becomes 0
again.
I've put a print statement in the constructor to ensure it is not recreated:
class RegisterPageVm {
RegisterPageVm({required this.entity}) {
print('new instance');
}
I can confirm it is only every constructed once. I have looked for all instances of vm.page.value = 0
and there is never code running that does that.
Any ideas what else I can check to figure out why vm.page.value
is getting reset to 0
upon popping the stack?