Questions tagged [inherited-widget]
63 questions
31
votes
10 answers
How to access Provider providers in Dialogs in Flutter
The Provider package makes use of InheritedWidget. This is a problem when I want to access a provider when I'm in a Dialog. If I load a dialog using
showDialog(... builder: (context) => MyDialog);
I can't access anything using InheritedWidget…

JustLearningAgain
- 2,227
- 4
- 34
- 50
19
votes
1 answer
Scoped Model, BLoC pattern, StreamBuilder and Inherited Widget(or Model) which one should I chose and why?
I think I have now at least a vague idea of how to use a BLoC, Stream Builder and Inherited Widget(or Model) in my app (nothing special, but for me it took time), but playing with the Scoped Model
I had a sort of existential crisis: I feel they can…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
18
votes
3 answers
Correct Flutter widget sequence to pull data on app load
I am running into an issue with flutter when I try to read data from local storage when the app loads.
I have an inherited widget that holds authentication information for the current user. When the app loads I want to look into local storage for…

TemporaryFix
- 2,008
- 3
- 30
- 54
11
votes
2 answers
InheritedWidget - The getter was called on null after navigator.push
I'm having trouble trying to access an InheritedWidget after navigating to a new widget.
I have my top level widget like this
class App extends StatelessWidget{
build(context){
return MaterialApp(
title: 'Iniciar Sesion',
…

Sebastian
- 3,666
- 2
- 19
- 32
8
votes
1 answer
ListView loses scroll position when using InheritedWidget in Flutter
After adding InheritedWidget to app I recognize that ListView loses scroll position (selected item index) when I come back to list from details screen using Pop().
I know that widget can be rebuild any time but maybe someone can suggest solution…

moonvader
- 19,761
- 18
- 67
- 116
8
votes
2 answers
Flutter: Access data from InheritedWidgets without context?
I see that I can access InheritedWidgets inside the build() method like this: final inheritedWidget = ChronoApp.of(context); but what if I want to access it somewhere else, say in initState() which has no context. How would I do this?

Jus10
- 14,519
- 21
- 52
- 77
7
votes
5 answers
Get InheritedWidget parameter in initState
i need some help understanding how to obtain data from inherited widget.
I usually get the parameter from my widget directly from the build method using
@override
Widget build(BuildContext context) {
//THIS METHOD
var data =…

Cristian Bregant
- 1,797
- 1
- 16
- 22
7
votes
2 answers
Flutter Error: "Widget cannot build because is already in the process of building"
I got this error:
I/flutter (29346): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (29346): The following assertion was thrown building MainLogic(dirty, state:…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
6
votes
2 answers
Why findAncestorWidgetOfExactType is O(N) and dependOnInheritedWidgetOfExactType is O(1)
in Flutter there are two functions :
findAncestorWidgetOfExactType
dependOnInheritedWidgetOfExactType
in the docs they say that: findAncestorWidgetOfExactType is relatively expensive (O(N) in the depth of the tree).
and…

grayHatEnigma
- 316
- 3
- 9
6
votes
1 answer
InheritedWidget confusion
The Flutter documentation for InheritedWidget says
Base class for widgets that efficiently propagate information down the tree.
To obtain the nearest instance of a particular type of inherited widget from > a build context, use…

ronald_s56
- 301
- 3
- 12
6
votes
1 answer
How do you create Services/Providers in Flutter?
Let's say I need a user service which has all my user variables and functions, and another item service with all item variables and functions, etc etc. I want all this data and functions available throughout the project, passing the user data where…

Jus10
- 14,519
- 21
- 52
- 77
4
votes
1 answer
Flutter- Understanding the lifecycle of Provider, Bloc and when to dispose the stream
Need to understand when we should Bloc pattern and life cycle of Bloc (how to release objects holding memory)
I have a screen where I am fetching the data from the server and data will be used for a single screen only. I am using Bloc pattern to…

Ankur Prakash
- 1,417
- 4
- 18
- 31
4
votes
2 answers
Flutter: Inherited Widget and Routes
I want to have an inherited widget at the root of my application, which will contain my data providers, which I would use throughout the app. So I have this inherited widget, but every time I try to load it I get this The getter 'data' was called on…

Jus10
- 14,519
- 21
- 52
- 77
3
votes
4 answers
Where to place a Provider Widget -- Flutter Provider Package
I am currently learning app development with Flutter and have started learning about the Provider package. I was having some difficulty and was getting the error:
"Could not find the correct Provider above this ... Widget"
I ended up moving the…

Shiv
- 109
- 6
3
votes
0 answers
Inherited Widget rebuilding whole Google Maps widget
Building an application with Flutter and liking it so far, but an annoying problem is bugging me.
I have a "main" Stateful Widget with a list of shops in attribute, a search bar, a "child" widget which is either a map or a list, and we can switch…

C. Grd
- 68
- 5