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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

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