Flutter Navigation: Fetching the previous Route











up vote
0
down vote

favorite












I have been doing some flutter development lately out of interests and I came upon the flutter navigator. I am using the default style way, so no routing lib is used(just Navigator.push/pop), however I would like to be able to fetch the previous route of the current rout(in other words fetching the route that initialised and called the current one.



At the moment I have a final field in each Route where I can recognise the caller, however this is a very bad way of doing it in addition of being unpractical especially when I have composed classes.



Any idea of how this can be achieved? Thanks










share|improve this question






















  • so you want to get he parent's Route object?
    – pskink
    2 days ago










  • If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
    – mquemazz
    2 days ago












  • what about adding your own listener to observers property?
    – pskink
    2 days ago










  • or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
    – pskink
    2 days ago












  • I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
    – mquemazz
    2 days ago















up vote
0
down vote

favorite












I have been doing some flutter development lately out of interests and I came upon the flutter navigator. I am using the default style way, so no routing lib is used(just Navigator.push/pop), however I would like to be able to fetch the previous route of the current rout(in other words fetching the route that initialised and called the current one.



At the moment I have a final field in each Route where I can recognise the caller, however this is a very bad way of doing it in addition of being unpractical especially when I have composed classes.



Any idea of how this can be achieved? Thanks










share|improve this question






















  • so you want to get he parent's Route object?
    – pskink
    2 days ago










  • If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
    – mquemazz
    2 days ago












  • what about adding your own listener to observers property?
    – pskink
    2 days ago










  • or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
    – pskink
    2 days ago












  • I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
    – mquemazz
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have been doing some flutter development lately out of interests and I came upon the flutter navigator. I am using the default style way, so no routing lib is used(just Navigator.push/pop), however I would like to be able to fetch the previous route of the current rout(in other words fetching the route that initialised and called the current one.



At the moment I have a final field in each Route where I can recognise the caller, however this is a very bad way of doing it in addition of being unpractical especially when I have composed classes.



Any idea of how this can be achieved? Thanks










share|improve this question













I have been doing some flutter development lately out of interests and I came upon the flutter navigator. I am using the default style way, so no routing lib is used(just Navigator.push/pop), however I would like to be able to fetch the previous route of the current rout(in other words fetching the route that initialised and called the current one.



At the moment I have a final field in each Route where I can recognise the caller, however this is a very bad way of doing it in addition of being unpractical especially when I have composed classes.



Any idea of how this can be achieved? Thanks







dart flutter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









mquemazz

1851311




1851311












  • so you want to get he parent's Route object?
    – pskink
    2 days ago










  • If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
    – mquemazz
    2 days ago












  • what about adding your own listener to observers property?
    – pskink
    2 days ago










  • or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
    – pskink
    2 days ago












  • I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
    – mquemazz
    2 days ago


















  • so you want to get he parent's Route object?
    – pskink
    2 days ago










  • If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
    – mquemazz
    2 days ago












  • what about adding your own listener to observers property?
    – pskink
    2 days ago










  • or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
    – pskink
    2 days ago












  • I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
    – mquemazz
    2 days ago
















so you want to get he parent's Route object?
– pskink
2 days ago




so you want to get he parent's Route object?
– pskink
2 days ago












If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
– mquemazz
2 days ago






If you mean by parent, the class that has called or navigated to the new route, then yes I would like to get it. The reason why I am asking this, I have a generic screen that can be used in different situations during the life cycle of the app. Based on the caller of this screen, it has to call other screens.
– mquemazz
2 days ago














what about adding your own listener to observers property?
– pskink
2 days ago




what about adding your own listener to observers property?
– pskink
2 days ago












or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
– pskink
2 days ago






or maybe docs.flutter.io/flutter/widgets/RouteAware-class.html (i have no idea how to use it though, as i "found" it 30 seconds ago...)?
– pskink
2 days ago














I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
– mquemazz
2 days ago




I am actually reading about it, I never used it either and didn't have the need for it. The interesting part is, there is an open ticket in the Flutter Repo, regarding something similar.
– mquemazz
2 days ago

















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',
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
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203543%2fflutter-navigation-fetching-the-previous-route%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203543%2fflutter-navigation-fetching-the-previous-route%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Landwehr

Reims

Javascript gets undefined on array