How to Converting a List of DateTime into Strings ?

This Article is posted by nikhilchaudhary12155 at 10/29/2019 4:05:34 AM



<p>Hello Everyone,Today we are talking about how to convert a list of date and time into string.First of all, you know about list.map concept before learning of these things. post-textitemprop="text]( The code block inside list.map is never executed.</p> <p>This is because list.map produces a lazy transformation of the list. The transformation function is executed only when elements are requested from it.</p> <p>You probably want to use:</p> <p><pre class="lang-dart prettyprint prettyprinted](kwd](varpln]( dates pun](=pln]( listpun](.pln](mappun](((typ](DateTimepln]( timepun]()pln]( pun]({pln]( kwd](varpln]( dateRange pun](=pln]( typ](DateFormatpun]((str](&quot;MM-dd-yy&quot;pun]().pln](formatpun]((pln](timepun]();pln]( kwd](returnpln]( dateRangepun](;pln]( pun](});pln]( printpun]((pln](datespun]();```</p> <p>In the code above, it is the print function that forces the transformation to run.</p> <p>Alternatively, you can transform the result of the list.map to a list using</p> <p>&lt;pre class=&quot;lang-dart prettyprint prettyprinted](kwd](varpln]( datesList pun](=pln]( datespun](.pln](toListpun](();```</p> <p>Again, this forces eager evaluation of the map transformation.</p> <p>![](../../Uploads/91847301-c22c-436f-8d0a-e74c90755cbb.pngwidth="50%height="auto](</p>


Tags: flutter flutterisfuture








0 Comments
Login to comment.
Recent Comments