Why it must be use the await for save/get local data in Flutter?










0














I want to save data to local(just a few data), and I find several package for do that (e.g shared_preferences,secure_storage,sqflite), but all of them are need to use await (Future), if I use these, I have to change my existing codes for wrap in Future, but I just feel that's very troublesome, so I am wondering why all of these are need to use await for save data? or can I use another easy way to do that?



Thanks!










share|improve this question


























    0














    I want to save data to local(just a few data), and I find several package for do that (e.g shared_preferences,secure_storage,sqflite), but all of them are need to use await (Future), if I use these, I have to change my existing codes for wrap in Future, but I just feel that's very troublesome, so I am wondering why all of these are need to use await for save data? or can I use another easy way to do that?



    Thanks!










    share|improve this question
























      0












      0








      0







      I want to save data to local(just a few data), and I find several package for do that (e.g shared_preferences,secure_storage,sqflite), but all of them are need to use await (Future), if I use these, I have to change my existing codes for wrap in Future, but I just feel that's very troublesome, so I am wondering why all of these are need to use await for save data? or can I use another easy way to do that?



      Thanks!










      share|improve this question













      I want to save data to local(just a few data), and I find several package for do that (e.g shared_preferences,secure_storage,sqflite), but all of them are need to use await (Future), if I use these, I have to change my existing codes for wrap in Future, but I just feel that's very troublesome, so I am wondering why all of these are need to use await for save data? or can I use another easy way to do that?



      Thanks!







      flutter local-storage






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 2:44









      Winson

      261210




      261210






















          3 Answers
          3






          active

          oldest

          votes


















          1














          await as the name suggest wait for some event without stopping following lines of code to execute because that work will take some milliseconds to perform. So, it's a good idea to use await which needs to have async in the function.



          There is other way of doing this work without using async-await.
          That's then().



          So, you go with this without having to add async to your function.



          performWork().then((result) ));





          share|improve this answer




















          • How does this answer Why it must be use the await for save/get local data in Flutter??
            – Rémi Rousselet
            Nov 12 '18 at 5:39










          • The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
            – CopsOnRoad
            Nov 12 '18 at 6:00










          • His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
            – Rémi Rousselet
            Nov 12 '18 at 6:21










          • Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
            – CopsOnRoad
            Nov 12 '18 at 6:51











          • yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
            – Winson
            Nov 12 '18 at 7:04



















          2














          To be clear: It is impossible to have a synchronous system call in flutter.



          This is due to an architectural decision: Instead of having the language bridge, Flutter uses two bus (one dart, one native) sending messages to each other.



          This is faster than by using a bridge but enforce asynchronous messages.






          share|improve this answer




















          • Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
            – CopsOnRoad
            Nov 12 '18 at 14:30


















          1














          If you do not wish to use await you can call then() on the Future object. Refer this link for more details.



          If you are working with Flutter you will definitely have to handle Future's there is no work around it.






          share|improve this answer




















          • anyway, thanks both of you! :)
            – Winson
            Nov 12 '18 at 7:30










          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%2f53255353%2fwhy-it-must-be-use-the-await-for-save-get-local-data-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









          1














          await as the name suggest wait for some event without stopping following lines of code to execute because that work will take some milliseconds to perform. So, it's a good idea to use await which needs to have async in the function.



          There is other way of doing this work without using async-await.
          That's then().



          So, you go with this without having to add async to your function.



          performWork().then((result) ));





          share|improve this answer




















          • How does this answer Why it must be use the await for save/get local data in Flutter??
            – Rémi Rousselet
            Nov 12 '18 at 5:39










          • The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
            – CopsOnRoad
            Nov 12 '18 at 6:00










          • His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
            – Rémi Rousselet
            Nov 12 '18 at 6:21










          • Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
            – CopsOnRoad
            Nov 12 '18 at 6:51











          • yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
            – Winson
            Nov 12 '18 at 7:04
















          1














          await as the name suggest wait for some event without stopping following lines of code to execute because that work will take some milliseconds to perform. So, it's a good idea to use await which needs to have async in the function.



          There is other way of doing this work without using async-await.
          That's then().



          So, you go with this without having to add async to your function.



          performWork().then((result) ));





          share|improve this answer




















          • How does this answer Why it must be use the await for save/get local data in Flutter??
            – Rémi Rousselet
            Nov 12 '18 at 5:39










          • The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
            – CopsOnRoad
            Nov 12 '18 at 6:00










          • His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
            – Rémi Rousselet
            Nov 12 '18 at 6:21










          • Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
            – CopsOnRoad
            Nov 12 '18 at 6:51











          • yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
            – Winson
            Nov 12 '18 at 7:04














          1












          1








          1






          await as the name suggest wait for some event without stopping following lines of code to execute because that work will take some milliseconds to perform. So, it's a good idea to use await which needs to have async in the function.



          There is other way of doing this work without using async-await.
          That's then().



          So, you go with this without having to add async to your function.



          performWork().then((result) ));





          share|improve this answer












          await as the name suggest wait for some event without stopping following lines of code to execute because that work will take some milliseconds to perform. So, it's a good idea to use await which needs to have async in the function.



          There is other way of doing this work without using async-await.
          That's then().



          So, you go with this without having to add async to your function.



          performWork().then((result) ));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 4:10









          CopsOnRoad

          2,92911018




          2,92911018











          • How does this answer Why it must be use the await for save/get local data in Flutter??
            – Rémi Rousselet
            Nov 12 '18 at 5:39










          • The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
            – CopsOnRoad
            Nov 12 '18 at 6:00










          • His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
            – Rémi Rousselet
            Nov 12 '18 at 6:21










          • Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
            – CopsOnRoad
            Nov 12 '18 at 6:51











          • yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
            – Winson
            Nov 12 '18 at 7:04

















          • How does this answer Why it must be use the await for save/get local data in Flutter??
            – Rémi Rousselet
            Nov 12 '18 at 5:39










          • The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
            – CopsOnRoad
            Nov 12 '18 at 6:00










          • His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
            – Rémi Rousselet
            Nov 12 '18 at 6:21










          • Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
            – CopsOnRoad
            Nov 12 '18 at 6:51











          • yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
            – Winson
            Nov 12 '18 at 7:04
















          How does this answer Why it must be use the await for save/get local data in Flutter??
          – Rémi Rousselet
          Nov 12 '18 at 5:39




          How does this answer Why it must be use the await for save/get local data in Flutter??
          – Rémi Rousselet
          Nov 12 '18 at 5:39












          The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
          – CopsOnRoad
          Nov 12 '18 at 6:00




          The question content also ask you is there a way to avoid async await. So this answers the body. Your answer answers title.
          – CopsOnRoad
          Nov 12 '18 at 6:00












          His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
          – Rémi Rousselet
          Nov 12 '18 at 6:21




          His content clearly ask why it's asynchronous. This is in comparison to Javascript for instance, where LocalStorage is synchronous
          – Rémi Rousselet
          Nov 12 '18 at 6:21












          Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
          – CopsOnRoad
          Nov 12 '18 at 6:51





          Did you read last line which says can I use another easy way to do that? Let OP decide whether my answer provides him solution or it is just irrelevant. Thanks :)
          – CopsOnRoad
          Nov 12 '18 at 6:51













          yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
          – Winson
          Nov 12 '18 at 7:04





          yes, thanks a lot, and my purpose that want to find another ways not just using await in these package, because I really don't want to change all of my codes! :)
          – Winson
          Nov 12 '18 at 7:04














          2














          To be clear: It is impossible to have a synchronous system call in flutter.



          This is due to an architectural decision: Instead of having the language bridge, Flutter uses two bus (one dart, one native) sending messages to each other.



          This is faster than by using a bridge but enforce asynchronous messages.






          share|improve this answer




















          • Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
            – CopsOnRoad
            Nov 12 '18 at 14:30















          2














          To be clear: It is impossible to have a synchronous system call in flutter.



          This is due to an architectural decision: Instead of having the language bridge, Flutter uses two bus (one dart, one native) sending messages to each other.



          This is faster than by using a bridge but enforce asynchronous messages.






          share|improve this answer




















          • Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
            – CopsOnRoad
            Nov 12 '18 at 14:30













          2












          2








          2






          To be clear: It is impossible to have a synchronous system call in flutter.



          This is due to an architectural decision: Instead of having the language bridge, Flutter uses two bus (one dart, one native) sending messages to each other.



          This is faster than by using a bridge but enforce asynchronous messages.






          share|improve this answer












          To be clear: It is impossible to have a synchronous system call in flutter.



          This is due to an architectural decision: Instead of having the language bridge, Flutter uses two bus (one dart, one native) sending messages to each other.



          This is faster than by using a bridge but enforce asynchronous messages.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 3:08









          Rémi Rousselet

          25.1k24884




          25.1k24884











          • Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
            – CopsOnRoad
            Nov 12 '18 at 14:30
















          • Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
            – CopsOnRoad
            Nov 12 '18 at 14:30















          Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
          – CopsOnRoad
          Nov 12 '18 at 14:30




          Can you now undo downvoting my answer because OP found it relevant to the question asked. Thanks
          – CopsOnRoad
          Nov 12 '18 at 14:30











          1














          If you do not wish to use await you can call then() on the Future object. Refer this link for more details.



          If you are working with Flutter you will definitely have to handle Future's there is no work around it.






          share|improve this answer




















          • anyway, thanks both of you! :)
            – Winson
            Nov 12 '18 at 7:30















          1














          If you do not wish to use await you can call then() on the Future object. Refer this link for more details.



          If you are working with Flutter you will definitely have to handle Future's there is no work around it.






          share|improve this answer




















          • anyway, thanks both of you! :)
            – Winson
            Nov 12 '18 at 7:30













          1












          1








          1






          If you do not wish to use await you can call then() on the Future object. Refer this link for more details.



          If you are working with Flutter you will definitely have to handle Future's there is no work around it.






          share|improve this answer












          If you do not wish to use await you can call then() on the Future object. Refer this link for more details.



          If you are working with Flutter you will definitely have to handle Future's there is no work around it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 4:17









          Thanthu

          274114




          274114











          • anyway, thanks both of you! :)
            – Winson
            Nov 12 '18 at 7:30
















          • anyway, thanks both of you! :)
            – Winson
            Nov 12 '18 at 7:30















          anyway, thanks both of you! :)
          – Winson
          Nov 12 '18 at 7:30




          anyway, thanks both of you! :)
          – Winson
          Nov 12 '18 at 7:30

















          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%2f53255353%2fwhy-it-must-be-use-the-await-for-save-get-local-data-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

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Syphilis

          Darth Vader #20