Pass WidgetRef to function or create function in build method? #3710
Answered
by
rrousselGit
DefinitiveIch
asked this question in
Q&A
-
Which of the 2 is better? class SomeWidget extends ConsumerWidget {
SomeWidget();
void defineFunctionWithWidgetRefAsParam(WidgetRef ref) {
ref.read(someProvider);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
void defineFunctionInBuild() {
ref.read(someProvider);
}
return SizedBox();
}
}
`` |
Beta Was this translation helpful? Give feedback.
Answered by
rrousselGit
Aug 19, 2024
Replies: 1 comment
-
Both are fine. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DefinitiveIch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both are fine.