Life cycle in flutter
Does flutter have a method like Activity.resume()
witch can tell developer the user has gone back to the activity.
When I pick the data from internet in Page-B and go back to Page-A, how can I let Page-A know that the data is prepared.

add a comment |
Does flutter have a method like Activity.resume()
witch can tell developer the user has gone back to the activity.
When I pick the data from internet in Page-B and go back to Page-A, how can I let Page-A know that the data is prepared.

I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59
add a comment |
Does flutter have a method like Activity.resume()
witch can tell developer the user has gone back to the activity.
When I pick the data from internet in Page-B and go back to Page-A, how can I let Page-A know that the data is prepared.

Does flutter have a method like Activity.resume()
witch can tell developer the user has gone back to the activity.
When I pick the data from internet in Page-B and go back to Page-A, how can I let Page-A know that the data is prepared.


edited Nov 24 '18 at 16:49


CopsOnRoad
2,94411018
2,94411018
asked Jan 5 '17 at 7:17


zhang qinglian
6116
6116
I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59
add a comment |
I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59
I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59
I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59
add a comment |
3 Answers
3
active
oldest
votes
There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart
You need to use WidgetsBindingObserver
add a comment |
createState():
When the Framework is instructed to build a StatefulWidget, it immediately calls createState()mounted is true:
When createState creates your state class, a buildContext is assigned to that state. BuildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here's a longer explanation.
All widgets have a bool this.mounted property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.initState():
This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must called super.initState().didChangeDependencies():
This method is called immediately after initState on the first time the widget is built.build():
This method is called often. It is required, and it must return a Widget.didUpdateWidget(Widget oldWidget):
If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called.
This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in initState.setState():
This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changeddeactivate():
Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.dispose():
Dispose is called when the State object is removed, which is permanent.
This method is where you should unsubscribe and cancel all animations, streams, etc.mounted is false:
The state object can never remount, and an error is thrown is setState is called.
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
add a comment |
here you can find how excatly you can return data from "Activity -B" back to "activity A"
add a comment |
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%2f41479255%2flife-cycle-in-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart
You need to use WidgetsBindingObserver
add a comment |
There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart
You need to use WidgetsBindingObserver
add a comment |
There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart
You need to use WidgetsBindingObserver
There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart
You need to use WidgetsBindingObserver
edited Nov 24 '18 at 16:41


CopsOnRoad
2,94411018
2,94411018
answered Jan 5 '17 at 8:03
Ian Hickson
2,1941111
2,1941111
add a comment |
add a comment |
createState():
When the Framework is instructed to build a StatefulWidget, it immediately calls createState()mounted is true:
When createState creates your state class, a buildContext is assigned to that state. BuildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here's a longer explanation.
All widgets have a bool this.mounted property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.initState():
This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must called super.initState().didChangeDependencies():
This method is called immediately after initState on the first time the widget is built.build():
This method is called often. It is required, and it must return a Widget.didUpdateWidget(Widget oldWidget):
If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called.
This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in initState.setState():
This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changeddeactivate():
Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.dispose():
Dispose is called when the State object is removed, which is permanent.
This method is where you should unsubscribe and cancel all animations, streams, etc.mounted is false:
The state object can never remount, and an error is thrown is setState is called.
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
add a comment |
createState():
When the Framework is instructed to build a StatefulWidget, it immediately calls createState()mounted is true:
When createState creates your state class, a buildContext is assigned to that state. BuildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here's a longer explanation.
All widgets have a bool this.mounted property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.initState():
This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must called super.initState().didChangeDependencies():
This method is called immediately after initState on the first time the widget is built.build():
This method is called often. It is required, and it must return a Widget.didUpdateWidget(Widget oldWidget):
If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called.
This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in initState.setState():
This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changeddeactivate():
Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.dispose():
Dispose is called when the State object is removed, which is permanent.
This method is where you should unsubscribe and cancel all animations, streams, etc.mounted is false:
The state object can never remount, and an error is thrown is setState is called.
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
add a comment |
createState():
When the Framework is instructed to build a StatefulWidget, it immediately calls createState()mounted is true:
When createState creates your state class, a buildContext is assigned to that state. BuildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here's a longer explanation.
All widgets have a bool this.mounted property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.initState():
This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must called super.initState().didChangeDependencies():
This method is called immediately after initState on the first time the widget is built.build():
This method is called often. It is required, and it must return a Widget.didUpdateWidget(Widget oldWidget):
If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called.
This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in initState.setState():
This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changeddeactivate():
Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.dispose():
Dispose is called when the State object is removed, which is permanent.
This method is where you should unsubscribe and cancel all animations, streams, etc.mounted is false:
The state object can never remount, and an error is thrown is setState is called.
createState():
When the Framework is instructed to build a StatefulWidget, it immediately calls createState()mounted is true:
When createState creates your state class, a buildContext is assigned to that state. BuildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here's a longer explanation.
All widgets have a bool this.mounted property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.initState():
This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must called super.initState().didChangeDependencies():
This method is called immediately after initState on the first time the widget is built.build():
This method is called often. It is required, and it must return a Widget.didUpdateWidget(Widget oldWidget):
If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called.
This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in initState.setState():
This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changeddeactivate():
Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.dispose():
Dispose is called when the State object is removed, which is permanent.
This method is where you should unsubscribe and cancel all animations, streams, etc.mounted is false:
The state object can never remount, and an error is thrown is setState is called.
answered Nov 19 '18 at 17:25


Shelly Pritchard
718
718
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
add a comment |
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
– Rap
Jan 2 at 3:25
add a comment |
here you can find how excatly you can return data from "Activity -B" back to "activity A"
add a comment |
here you can find how excatly you can return data from "Activity -B" back to "activity A"
add a comment |
here you can find how excatly you can return data from "Activity -B" back to "activity A"
here you can find how excatly you can return data from "Activity -B" back to "activity A"
answered Nov 24 '18 at 17:08
Saed Nabil
1,17828
1,17828
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f41479255%2flife-cycle-in-flutter%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
I don't fully understand the question: Do you simply want to pass data to the screen before the current screen on the navigation stack?
– Renato Stauffer
Dec 31 '17 at 15:59