Skip to content

Instantly share code, notes, and snippets.

@naveenadi
Forked from rei-codes/with_hooks.dart
Created April 12, 2022 16:15
Show Gist options
  • Save naveenadi/5f2a7a0a8fb1461dc34f3acfa2132fe6 to your computer and use it in GitHub Desktop.
Save naveenadi/5f2a7a0a8fb1461dc34f3acfa2132fe6 to your computer and use it in GitHub Desktop.
with useEffect
class HomePage extends HookWidget {
@override
Widget build(BuildContext context) {
useEffect(
() {
// initState
return () {
// dispose
};
},
[], // didUpdateWidget
// null: fires in every change
// empty list: fires only once on the first time
// list with items: fires when any of the items on the list change.
);
return Container();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment