rrousselGit / riverpod

A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
https://riverpod.dev
MIT License
6.17k stars 943 forks source link

LateInitializationError #847

Closed kamyar75 closed 2 years ago

kamyar75 commented 2 years ago

Describe the bug LateInitializationError when sometimes use the first time run hookConsumerWidget. just first run. if I go to another page,and come back target page,soleved, but first time ...

To Reproduce

can't handle MapController

The following LateError was thrown while handling a gesture: LateInitializationError: Field '_state' has not been initialized.

When the exception was thrown, this was the stack: C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 251:49 throw packages/flutter_map/src/map/map.dart 16:23 get [_state] packages/flutter_map/src/map/map.dart 64:31 get center packages/mycity_sup/ui/app/app_setting_info_part.dart 822:47 packages/flutter/src/material/ink_well.dart 989:21
Expected behavior it need to run without error.

TimWhiting commented 2 years ago

If you look at the stack, it doesn't seem to be related to riverpod or hooks. It is the flutter_map package that is trying to access ._state without it being initialized. Check to make sure you are using that package properly, or provide a minimally reproducible example.

For example check to see if it happens with a stateful widget as well

kamyar75 commented 2 years ago

with stateful widget worked.

TimWhiting commented 2 years ago

Can you give a sample of what it looks like in StatefulWidget versus HookConsumerWidget, as well as what version of riverpod you are using?

kamyar75 commented 2 years ago

I am using 1dev.11 version .

rrousselGit commented 2 years ago

As Tim mentioned, it's quite likely unrelated to hooks/riverpod. Please share some code, so that we can help. Otherwise we cannot do anything