Life cycle in flutter












10














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.










share|improve this question
























  • 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
















10














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.










share|improve this question
























  • 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














10












10








10


3





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.










share|improve this question















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.







flutter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












3 Answers
3






active

oldest

votes


















11














There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart



You need to use WidgetsBindingObserver






share|improve this answer































    0















    1. createState():
      When the Framework is instructed to build a StatefulWidget, it immediately calls createState()


    2. 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.


    3. 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().


    4. didChangeDependencies():
      This method is called immediately after initState on the first time the widget is built.


    5. build():
      This method is called often. It is required, and it must return a Widget.


    6. 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.


    7. setState():
      This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed


    8. deactivate():
      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.


    9. 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.


    10. mounted is false:
      The state object can never remount, and an error is thrown is setState is called.







    share|improve this answer





















    • Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
      – Rap
      Jan 2 at 3:25



















    0














    here you can find how excatly you can return data from "Activity -B" back to "activity A"






    share|improve this answer





















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


      }
      });














      draft saved

      draft discarded


















      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









      11














      There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart



      You need to use WidgetsBindingObserver






      share|improve this answer




























        11














        There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart



        You need to use WidgetsBindingObserver






        share|improve this answer


























          11












          11








          11






          There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart



          You need to use WidgetsBindingObserver






          share|improve this answer














          There's an example here: https://github.com/flutter/flutter/blob/master/examples/layers/services/lifecycle.dart



          You need to use WidgetsBindingObserver







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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

























              0















              1. createState():
                When the Framework is instructed to build a StatefulWidget, it immediately calls createState()


              2. 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.


              3. 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().


              4. didChangeDependencies():
                This method is called immediately after initState on the first time the widget is built.


              5. build():
                This method is called often. It is required, and it must return a Widget.


              6. 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.


              7. setState():
                This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed


              8. deactivate():
                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.


              9. 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.


              10. mounted is false:
                The state object can never remount, and an error is thrown is setState is called.







              share|improve this answer





















              • Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
                – Rap
                Jan 2 at 3:25
















              0















              1. createState():
                When the Framework is instructed to build a StatefulWidget, it immediately calls createState()


              2. 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.


              3. 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().


              4. didChangeDependencies():
                This method is called immediately after initState on the first time the widget is built.


              5. build():
                This method is called often. It is required, and it must return a Widget.


              6. 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.


              7. setState():
                This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed


              8. deactivate():
                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.


              9. 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.


              10. mounted is false:
                The state object can never remount, and an error is thrown is setState is called.







              share|improve this answer





















              • Source for @Shelly's information: flutterbyexample.com/stateful-widget-lifecycle
                – Rap
                Jan 2 at 3:25














              0












              0








              0







              1. createState():
                When the Framework is instructed to build a StatefulWidget, it immediately calls createState()


              2. 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.


              3. 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().


              4. didChangeDependencies():
                This method is called immediately after initState on the first time the widget is built.


              5. build():
                This method is called often. It is required, and it must return a Widget.


              6. 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.


              7. setState():
                This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed


              8. deactivate():
                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.


              9. 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.


              10. mounted is false:
                The state object can never remount, and an error is thrown is setState is called.







              share|improve this answer













              1. createState():
                When the Framework is instructed to build a StatefulWidget, it immediately calls createState()


              2. 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.


              3. 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().


              4. didChangeDependencies():
                This method is called immediately after initState on the first time the widget is built.


              5. build():
                This method is called often. It is required, and it must return a Widget.


              6. 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.


              7. setState():
                This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed


              8. deactivate():
                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.


              9. 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.


              10. mounted is false:
                The state object can never remount, and an error is thrown is setState is called.








              share|improve this answer












              share|improve this answer



              share|improve this answer










              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


















              • 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











              0














              here you can find how excatly you can return data from "Activity -B" back to "activity A"






              share|improve this answer


























                0














                here you can find how excatly you can return data from "Activity -B" back to "activity A"






                share|improve this answer
























                  0












                  0








                  0






                  here you can find how excatly you can return data from "Activity -B" back to "activity A"






                  share|improve this answer












                  here you can find how excatly you can return data from "Activity -B" back to "activity A"







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 24 '18 at 17:08









                  Saed Nabil

                  1,17828




                  1,17828






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      MongoDB - Not Authorized To Execute Command

                      How to fix TextFormField cause rebuild widget in Flutter

                      in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith