You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current example shows the creation of a AnimController, but doesn't show you how to use it. Assuming you want to actually start it, you need some sort of init() hook. This is initially where I got stuck when first coming into Hooks, and I think the docs could do a better job here.
First, I think it would be extremely beneficial to just have a code snippet like this near the top of the docs:
In order to init and dispose with Hooks, you can call useEffect, and pass it an empty set of dependencies []:
Widget build(){
useEffect(
(){
// Do init stuff
return (){ //Do dispose stuff };
}, [ ] ) // pass an empty list of deps so this only fires once
);
}
This would have cleared up so much for me as someone who had zero prior knowledge with hooks (and did not want to dive into extensive react docs).
Additionally, changing the initial AnimController example to call controller.forward() would make it a much more practical example and answer the immediate question every Flutter dev would have when reading that example, which is "so, where & how do I start it?"
The text was updated successfully, but these errors were encountered:
The current example shows the creation of a AnimController, but doesn't show you how to use it. Assuming you want to actually start it, you need some sort of init() hook. This is initially where I got stuck when first coming into Hooks, and I think the docs could do a better job here.
First, I think it would be extremely beneficial to just have a code snippet like this near the top of the docs:
In order to init and dispose with Hooks, you can call
useEffect
, and pass it an empty set of dependencies[]
:This would have cleared up so much for me as someone who had zero prior knowledge with hooks (and did not want to dive into extensive react docs).
Additionally, changing the initial AnimController example to call
controller.forward()
would make it a much more practical example and answer the immediate question every Flutter dev would have when reading that example, which is "so, where & how do I start it?"The text was updated successfully, but these errors were encountered: