Comments (4)
What's the "bug" widget?
from riverpod.
What's the "bug" widget?
Sorry I meant TestWidget. I've just updated it.
from riverpod.
Your TestNotifier.build
is to blame.
It is marked as async, which makes the initialisation, well, async. So you're effectively setting the state to 7 before it is initialised to 5.
Essentially you're setting the state during AsyncLoading
.
Remove the async
and you're good to go.
@Riverpod(keepAlive: true)
class Test extends _$Test {
@override
FutureOr<int> build() {
return 5;
}
void updateWith(int value) {
state = AsyncData(value);
}
}
from riverpod.
An alternative is to await for the state to be initialized before modifying it.
You can do:
await container.read(testProvider.future);
container.read(testProvider.notifier).updateWith(7);
from riverpod.
Related Issues (20)
- Infinitely call child's `useEffect` when parent and child both `extends HookConsumerWidget` HOT 2
- riverpod_lint didn't show assists (in context menu) HOT 10
- Would separating asyncValue into its own package be useful? HOT 1
- Overriden providers are not passed to dialogs or modals HOT 5
- Unexpected dispose behavior in AutoDisposeProvider with nested watch methods HOT 3
- `Provider1` will never get disposed if `Provider2` gets disposed before it listens to or watches `Provider1` HOT 1
- Provider delegates onCancel and onDispose aren't invoked after invalidation when there are no remaining listeners HOT 3
- state works weird HOT 1
- Provider gets disposed before future completes when using `ref.read(provider.future)` HOT 4
- Pagination approach at pub example won't dispose fetchPackagesProvider of a page even if it's out of screen
- how to use NotifierProvider.family, always wrong HOT 3
- FamilyAsyncNotifying non-stop loop calling issue HOT 1
- How to listen to the state of a FutureProvider without calling it? HOT 1
- ProviderElementBase runOnDispose HOT 1
- Migrate old StateProvider to riverpod generator HOT 1
- ref.listen being triggered twice from screen and detail screen HOT 1
- A future provider that watch the future of a stream provider is updates twice when the stream provider receives a new value. HOT 1
- The argument type 'Future<InfoPageClass?>' can't be assigned to the parameter type 'ProviderListenable<dynamic>'. HOT 2
- Floating Action Button not correctly disabled during mutation
- Providers dispose after log out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riverpod.