Getting parent object info from Flutter app
I’m creating mobile application with Flutter.
This application has two forms (screens).
For example:
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
And
class ListScreen extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
As you could see I’m using shared appBar which instantiates from external class (AdvertAppBar
).
Is there any way to know from appBar class what the class of parent object (MainScreen
or ListScreen
)?
dart flutter
add a comment |
I’m creating mobile application with Flutter.
This application has two forms (screens).
For example:
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
And
class ListScreen extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
As you could see I’m using shared appBar which instantiates from external class (AdvertAppBar
).
Is there any way to know from appBar class what the class of parent object (MainScreen
or ListScreen
)?
dart flutter
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into yourAdvertAppBar
class. What exactly are you trying to acheive?
– Jordan Davies
Jan 2 at 13:15
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
@JordanDavies From MainScreen I want to call ListScreen(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but fromListScreen
I want only refresh content of theListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?
– Alex Zhulin
Jan 2 at 13:34
From what I understood from your question is that you are trying to only load the content of yourListView
widget without reloading yourappBar
am I right ?
– Ali Hussam
Jan 2 at 17:43
add a comment |
I’m creating mobile application with Flutter.
This application has two forms (screens).
For example:
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
And
class ListScreen extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
As you could see I’m using shared appBar which instantiates from external class (AdvertAppBar
).
Is there any way to know from appBar class what the class of parent object (MainScreen
or ListScreen
)?
dart flutter
I’m creating mobile application with Flutter.
This application has two forms (screens).
For example:
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
And
class ListScreen extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AdvertAppBar(context),
body: Container(…),
),
);
}
}
As you could see I’m using shared appBar which instantiates from external class (AdvertAppBar
).
Is there any way to know from appBar class what the class of parent object (MainScreen
or ListScreen
)?
dart flutter
dart flutter
asked Jan 2 at 12:21
Alex ZhulinAlex Zhulin
4921120
4921120
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into yourAdvertAppBar
class. What exactly are you trying to acheive?
– Jordan Davies
Jan 2 at 13:15
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
@JordanDavies From MainScreen I want to call ListScreen(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but fromListScreen
I want only refresh content of theListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?
– Alex Zhulin
Jan 2 at 13:34
From what I understood from your question is that you are trying to only load the content of yourListView
widget without reloading yourappBar
am I right ?
– Ali Hussam
Jan 2 at 17:43
add a comment |
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into yourAdvertAppBar
class. What exactly are you trying to acheive?
– Jordan Davies
Jan 2 at 13:15
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
@JordanDavies From MainScreen I want to call ListScreen(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but fromListScreen
I want only refresh content of theListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?
– Alex Zhulin
Jan 2 at 13:34
From what I understood from your question is that you are trying to only load the content of yourListView
widget without reloading yourappBar
am I right ?
– Ali Hussam
Jan 2 at 17:43
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into your
AdvertAppBar
class. What exactly are you trying to acheive?– Jordan Davies
Jan 2 at 13:15
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into your
AdvertAppBar
class. What exactly are you trying to acheive?– Jordan Davies
Jan 2 at 13:15
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
@JordanDavies From MainScreen I want to call ListScreen
(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but from ListScreen
I want only refresh content of the ListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?– Alex Zhulin
Jan 2 at 13:34
@JordanDavies From MainScreen I want to call ListScreen
(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but from ListScreen
I want only refresh content of the ListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?– Alex Zhulin
Jan 2 at 13:34
From what I understood from your question is that you are trying to only load the content of your
ListView
widget without reloading your appBar
am I right ?– Ali Hussam
Jan 2 at 17:43
From what I understood from your question is that you are trying to only load the content of your
ListView
widget without reloading your appBar
am I right ?– Ali Hussam
Jan 2 at 17:43
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006302%2fgetting-parent-object-info-from-flutter-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006302%2fgetting-parent-object-info-from-flutter-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You may be able to do this using the inheritedWidgetOfExactType method but it might be better if you simply pass data into your
AdvertAppBar
class. What exactly are you trying to acheive?– Jordan Davies
Jan 2 at 13:15
did you context.widget.runtimeType
– Ahmed
Jan 2 at 13:18
@JordanDavies From MainScreen I want to call ListScreen
(Navigator.push(context, MaterialPageRoute(builder: (context) => ListScreen()),);
), but fromListScreen
I want only refresh content of theListScreen
. Yeah, I can pass some parameter (say current form name) into AdvertAppBar constructor, but I think is there some more appropriate approach?– Alex Zhulin
Jan 2 at 13:34
From what I understood from your question is that you are trying to only load the content of your
ListView
widget without reloading yourappBar
am I right ?– Ali Hussam
Jan 2 at 17:43