How to access and edit a value of a existent key of a map that's inside a list on Dart/Flutter?Declare a List of Map in a class with Dart and FlutterCreate a countdown timer that prints a remaining time every 5 seconds for each value in a listCompare List with Value in Dart / FlutterCheck value in array exists Flutter dartHow to implement persistent stopwatch in Flutter?Sort a list of objects in Flutter (Dart) by property valueFlutter/Dart how to groupBy list of mapsUsing a list to access a function in dart flutterHow do i iterate JSON Map and retrieve key-value results in flutter DartDart, Nested classes, how to access child class variables

Wouldn't putting an electronic key inside a small Faraday cage render it completely useless?

Why would "dead languages" be the only languages that spells could be written in?

Can you take the Dodge action while prone?

Do grungs have a written language?

In the Seventh Seal why does Death let the chess game happen?

How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant

Minor differences between two recorded guitars

Is there a standard definition of the "stall" phenomena?

Was the 45.9°C temperature in France in June 2019 the highest ever recorded in France?

Why do Martians have to wear space helmets?

Why no parachutes in the Orion AA2 abort test?

I'm feeling like my character doesn't fit the campaign

What do I need to see before Spider-Man: Far From Home?

Why does "sattsehen" take accusative "mich", not dative "mir"? Even though it is not "me" that I'm looking at?

Is reasonable to assume that the 食 in 月食/日食 can be interpreted as the sun/moon being "eaten" during an eclipse?

How to play a D major chord lower than the open E major chord on guitar?

Is this car delivery via Ebay Motors on Craigslist a scam?

How to get the speed of my spaceship?

How do I talk to my wife about unrealistic expectations?

What instances can be solved today by modern solvers (pure LP)?

How to deal with a Murder Hobo Paladin?

How do I check that users don't write down their passwords?

Gory anime with pink haired girl escaping an asylum

What is the shape of the upper boundary of water hitting a screen?



How to access and edit a value of a existent key of a map that's inside a list on Dart/Flutter?


Declare a List of Map in a class with Dart and FlutterCreate a countdown timer that prints a remaining time every 5 seconds for each value in a listCompare List with Value in Dart / FlutterCheck value in array exists Flutter dartHow to implement persistent stopwatch in Flutter?Sort a list of objects in Flutter (Dart) by property valueFlutter/Dart how to groupBy list of mapsUsing a list to access a function in dart flutterHow do i iterate JSON Map and retrieve key-value results in flutter DartDart, Nested classes, how to access child class variables






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm create a list of maps, each map have two keys ["title"] and ["time"], all the values of keys is submitted in a setState method, with the values submited as Strings by a button, and a map object is added inside the list, that's List _tasks = [], so what I would like to do is access the ["time"] element of the last Map added in the list and be able to change the value.



This is part of a little project of application, to help me to learn more about Flutter. The repository of application is on Github on https://github.com/jsdaniell/remindme



The list is declared:



List _tasks = [];


The function that's adding a map object to the list:



void _addTask() 
setState(
()
Map<String, dynamic> newTask = Map();
newTask["title"] = _taskController.text;
newTask["time"] = _timeGlobal.toString();
_taskController.text = "";
_tasks.add(newTask);


,
);




The point is that I want to subtract a value of 1 every second of variable _timeGlobal, what's a int in the global scope and is the value that is set as a String in the ["time"] in the Map, so I write this code:



 String countdownTime(Map newTask) 

Timer timer = new Timer.periodic(new Duration(seconds: 1), (timer)

// Here I want to access the value of ["time"] element, where's in the last position of list and update the value.

_saveData();

return Home();

);

// Stop the periodic timer using another timer which runs only once after specified duration

new Timer(new Duration(minutes: _timeGlobal), ()
timer.cancel();
);



I hope that have some way to access the last map in a list of maps, and a specific key on this map.










share|improve this question






























    0















    I'm create a list of maps, each map have two keys ["title"] and ["time"], all the values of keys is submitted in a setState method, with the values submited as Strings by a button, and a map object is added inside the list, that's List _tasks = [], so what I would like to do is access the ["time"] element of the last Map added in the list and be able to change the value.



    This is part of a little project of application, to help me to learn more about Flutter. The repository of application is on Github on https://github.com/jsdaniell/remindme



    The list is declared:



    List _tasks = [];


    The function that's adding a map object to the list:



    void _addTask() 
    setState(
    ()
    Map<String, dynamic> newTask = Map();
    newTask["title"] = _taskController.text;
    newTask["time"] = _timeGlobal.toString();
    _taskController.text = "";
    _tasks.add(newTask);


    ,
    );




    The point is that I want to subtract a value of 1 every second of variable _timeGlobal, what's a int in the global scope and is the value that is set as a String in the ["time"] in the Map, so I write this code:



     String countdownTime(Map newTask) 

    Timer timer = new Timer.periodic(new Duration(seconds: 1), (timer)

    // Here I want to access the value of ["time"] element, where's in the last position of list and update the value.

    _saveData();

    return Home();

    );

    // Stop the periodic timer using another timer which runs only once after specified duration

    new Timer(new Duration(minutes: _timeGlobal), ()
    timer.cancel();
    );



    I hope that have some way to access the last map in a list of maps, and a specific key on this map.










    share|improve this question


























      0












      0








      0








      I'm create a list of maps, each map have two keys ["title"] and ["time"], all the values of keys is submitted in a setState method, with the values submited as Strings by a button, and a map object is added inside the list, that's List _tasks = [], so what I would like to do is access the ["time"] element of the last Map added in the list and be able to change the value.



      This is part of a little project of application, to help me to learn more about Flutter. The repository of application is on Github on https://github.com/jsdaniell/remindme



      The list is declared:



      List _tasks = [];


      The function that's adding a map object to the list:



      void _addTask() 
      setState(
      ()
      Map<String, dynamic> newTask = Map();
      newTask["title"] = _taskController.text;
      newTask["time"] = _timeGlobal.toString();
      _taskController.text = "";
      _tasks.add(newTask);


      ,
      );




      The point is that I want to subtract a value of 1 every second of variable _timeGlobal, what's a int in the global scope and is the value that is set as a String in the ["time"] in the Map, so I write this code:



       String countdownTime(Map newTask) 

      Timer timer = new Timer.periodic(new Duration(seconds: 1), (timer)

      // Here I want to access the value of ["time"] element, where's in the last position of list and update the value.

      _saveData();

      return Home();

      );

      // Stop the periodic timer using another timer which runs only once after specified duration

      new Timer(new Duration(minutes: _timeGlobal), ()
      timer.cancel();
      );



      I hope that have some way to access the last map in a list of maps, and a specific key on this map.










      share|improve this question
















      I'm create a list of maps, each map have two keys ["title"] and ["time"], all the values of keys is submitted in a setState method, with the values submited as Strings by a button, and a map object is added inside the list, that's List _tasks = [], so what I would like to do is access the ["time"] element of the last Map added in the list and be able to change the value.



      This is part of a little project of application, to help me to learn more about Flutter. The repository of application is on Github on https://github.com/jsdaniell/remindme



      The list is declared:



      List _tasks = [];


      The function that's adding a map object to the list:



      void _addTask() 
      setState(
      ()
      Map<String, dynamic> newTask = Map();
      newTask["title"] = _taskController.text;
      newTask["time"] = _timeGlobal.toString();
      _taskController.text = "";
      _tasks.add(newTask);


      ,
      );




      The point is that I want to subtract a value of 1 every second of variable _timeGlobal, what's a int in the global scope and is the value that is set as a String in the ["time"] in the Map, so I write this code:



       String countdownTime(Map newTask) 

      Timer timer = new Timer.periodic(new Duration(seconds: 1), (timer)

      // Here I want to access the value of ["time"] element, where's in the last position of list and update the value.

      _saveData();

      return Home();

      );

      // Stop the periodic timer using another timer which runs only once after specified duration

      new Timer(new Duration(minutes: _timeGlobal), ()
      timer.cancel();
      );



      I hope that have some way to access the last map in a list of maps, and a specific key on this map.







      dart flutter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 1:39









      Tomka Koliada

      1,2702 gold badges8 silver badges28 bronze badges




      1,2702 gold badges8 silver badges28 bronze badges










      asked Mar 25 at 20:32









      jsdanielljsdaniell

      62 bronze badges




      62 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          to access to the last element in the list you can use :
          _tasks[_tasks.length - 1];
          so if you want the "time" key from the Map thats inside the last element of your list use :
          var lastTime = _tasks[_tasks.length - 1]["time"];






          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%2f55345975%2fhow-to-access-and-edit-a-value-of-a-existent-key-of-a-map-thats-inside-a-list-o%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            to access to the last element in the list you can use :
            _tasks[_tasks.length - 1];
            so if you want the "time" key from the Map thats inside the last element of your list use :
            var lastTime = _tasks[_tasks.length - 1]["time"];






            share|improve this answer





























              0














              to access to the last element in the list you can use :
              _tasks[_tasks.length - 1];
              so if you want the "time" key from the Map thats inside the last element of your list use :
              var lastTime = _tasks[_tasks.length - 1]["time"];






              share|improve this answer



























                0












                0








                0







                to access to the last element in the list you can use :
                _tasks[_tasks.length - 1];
                so if you want the "time" key from the Map thats inside the last element of your list use :
                var lastTime = _tasks[_tasks.length - 1]["time"];






                share|improve this answer















                to access to the last element in the list you can use :
                _tasks[_tasks.length - 1];
                so if you want the "time" key from the Map thats inside the last element of your list use :
                var lastTime = _tasks[_tasks.length - 1]["time"];







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 25 at 22:06

























                answered Mar 25 at 22:00









                abdalmonemabdalmonem

                1445 bronze badges




                1445 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345975%2fhow-to-access-and-edit-a-value-of-a-existent-key-of-a-map-thats-inside-a-list-o%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 preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                    Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?