on-internet
← Community

Flutter - Which Nested Context to Use?

Stack Overflow ·

When working with Flutter, should you always prefer the closest BuildContext for doing activities like navigation, checking for mounted, getting parent objects using .of(), or is it more nuanced? Consider as an example where in the build method of a Widget I might have some sub-view or action which is nested within another Context, perhaps by a ValueListenableBuilder: Widget build(BuildContext context) { final theme = Theme.of(context); /* Obvious, since there's only one context */ return Column( children: [ ValueListenableBuilder( valueListenable: vm.isLoading, builder: (innerContext, isLoadi

Comments

Sign in or sign up to comment and upvote.

No comments yet.