Questions tagged [inherited-widget]
63 questions
3
votes
2 answers
How to dispose bloc when using Inherited Widget?
I have made a simple app using bloc and InheritedWidget.
Following is the code
class Bloc {
final StreamController _changeColor = PublishSubject();
Function(bool) get changeColour => _changeColor.sink.add;
Stream get…

BraveEvidence
- 53
- 11
- 45
- 119
2
votes
1 answer
Default Inherited Widget in Flutter
I'm looking into InheritedWidget to learn and I want to know about the default InheritedWidgets provided by Flutter.
I've come to know that the MediaQuery class is by default InheritedWidget in Flutter and I'm guessing there are more of it.
If…

NøBi Mac
- 505
- 5
- 15
2
votes
0 answers
Does Flutter dependOnInheritedWidgetOfExactType record which method it was called from?
I have been playing around with InheritedWidgeta etc. lately, and one thing that I don't understand is this sentence form the documentation of dependOnInheritedWidgetOfExactType…

wujek
- 10,112
- 12
- 52
- 88
2
votes
1 answer
How to access data of an InheritedWidget with pushed routes?
So I have an InheritedWidget which holds a token.
class TokenHolder extends InheritedWidget {
final String token;
const TokenHolder({@required this.token, @required Widget child})
: assert(child != null),
super(child: child);
…

Magnuti
- 63
- 9
2
votes
3 answers
Flutter: How Should I Use an InheritedWidget?
Introduction: I believe that this problem in principle might be shared, but I feel that this specific application is not. I humbly submit it for consideration, so please be gentle. I have stumbled into a clear trap here with my code, and I simply…

George Lee
- 814
- 18
- 34
2
votes
0 answers
How to save data before widget got disposed
I'm trying to save a value back to InheritedWidget before the widget is disposed of,
void disposed() {
AppInheritedWidget.of(context).update(value);
super.disposed();
}
but got the following error:
Is there a good way to save value before…

Panda World
- 1,704
- 1
- 20
- 28
2
votes
1 answer
Flutter trigger action in child with InheritedWidget
I have a dice-rolling MaterialApp. When the floatingButton is pressed I want to trigger a "dice-roll" on the children. I'm trying to use the InheritedWidget, but most examples I've seen appear to do the opposite, trigger a parent change from the…

icicleking
- 1,029
- 14
- 38
2
votes
1 answer
Using ancestorInheritedElementForWidgetOfExactType in flutter
I have a chat object in a InheritedWidget above to root widget of my app. I want to access this object within initState to set the initial state of a child widget. I've the following code:
void initState() {
super.initState();
final…

Amol Borkar
- 2,321
- 7
- 32
- 63
2
votes
1 answer
Flutter - InheritedModel still update child even if it does not match an aspect
Good day. I've watched a video about Flutter's InheritedModel and got interested on it. Unfortunately, I can't seems to make it work properly.
Summary: Need help how to properly implement InheritedModel.
Expected Code Output: Widget CountText…

Kokuou
- 129
- 2
- 9
1
vote
1 answer
Parent widget rebuilding will not cause sub-widgets rubuild?
/// Whether the framework should notify widgets that inherit from this widget.
///
/// When this widget is rebuilt, sometimes we need to rebuild the widgets that
/// inherit from this widget but sometimes we do not. For example, if the data
…

ximmyxiao
- 2,622
- 3
- 20
- 35
1
vote
1 answer
Streamprovider i am getting this issue "The following ProviderNotFoundException was thrown building ConsumerStreamData
main.dart file contain all the providers
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context)=>AppData()),
ChangeNotifierProvider(create: (context)=> UtilData()),
…

Nns_ninteyFIve
- 439
- 4
- 12
1
vote
0 answers
Multiple widgets use the same global key , A globalkey can only be specified on one widget at a time in the widget tree
when I am using this inherited widget sometimes I had getting the issue , multiple widgets using same global key , I don't know why it shows the issue , some times in the release build app shows a full black screen , is this black screen shown…

Nns_ninteyFIve
- 439
- 4
- 12
1
vote
0 answers
flutter dependOnInheritedWidgetOfExactType() returns null
I am trying to use InheritedWidget approach to share state down the Widget tree. For this, I am making a simple counter app. You can add, subtract, multiply or divide the counter however you like.
It's a small demo so best practices are not…

Ariel
- 2,471
- 1
- 26
- 43
1
vote
0 answers
Add AppBar actions from Scaffold children such as from Fragment.onCreateOptionsMenu in Android (using InheritedWidget)
In Android, every Fragment can partecipate in populating the options menu (aka "appBar actions", in flutter terms) of the activity, using the Fragment.onCreateOptionsMenu callback.
I would like a similar mechanism also in flutter, i.e. that some…

Mabsten
- 1,570
- 11
- 16
1
vote
1 answer
Update value of variable of inherited widget
This is my login code for the app I am making. I want to update token in parent_inherit(Inherited Widget) which i am getting after posting the request.But I am not able to understand how to update value of the variable of Inherited widget explicity…

Gautam Goyal
- 230
- 1
- 4
- 16