logo icon
Taninut.com

131

 
 
 
Content ID131
Category ID3
Writer ID(not set)
User ID(not set)
Lang Modeth
Content Nameเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Content Urlเรียนรู้ประเภทตัวแปร-List-Set-และ-Map-ใน-Flutter
Content Desc<p data-pm-slice="1 1 []">ใน Flutter มีการใช้งานตัวแปร List, Set, และ Map เพื่อจัดการกับข้อมูลในรูปแบบต่างๆ ดังนี้</p>
<ol>
<li>
<p>List: คือตัวแปรที่ใช้เก็บข้อมูลในลักษณะของลำดับ โดยสามารถเพิ่ม ลบ และเรียกใช้ข้อมูลได้ตามลำดับ สามารถประกาศตัวแปร List ใน Flutter ได้ดังนี้</p>
</li>
</ol>
<pre style="padding-left: 40px;"><code>List&lt;String&gt; fruits = ['apple', 'banana', 'orange'];</code></pre>
<ol start="2">
<li>
<p>Set: คือตัวแปรที่ใช้เก็บข้อมูลในลักษณะของเซต โดยจะไม่มีการเก็บข้อมูลที่ซ้ำกัน สามารถประกาศตัวแปร Set ใน Flutter ได้ดังนี้</p>
</li>
</ol>
<pre style="padding-left: 40px;"><code>Set&lt;String&gt; uniqueFruits = {'apple', 'banana', 'orange'};</code></pre>
<ol start="3">
<li>
<p>Map: คือตัวแปรที่ใช้เก็บข้อมูลในลักษณะของ key-value pairs โดยใช้ key เพื่อเข้าถึงข้อมูล value สามารถประกาศตัวแปร Map ใน Flutter ได้ดังนี้</p>
</li>
</ol>
<pre style="padding-left: 40px;"><code>Map&lt;String, int&gt; fruitPrices = {'apple': 10, 'banana': 15, 'orange': 20};</code></pre>
<p>การเข้าถึงข้อมูลในตัวแปร List, Set, และ Map ใน Flutter สามารถทำได้โดยใช้ index ในกรณีของ List และ Set หรือ key ในกรณีของ Map ดังนี้</p>
<pre style="padding-left: 40px;"><code>// Accessing List and Set<br>print(fruits[0]); // Output: apple<br>print(uniqueFruits.elementAt(1)); // Output: banana<br><br>// Accessing Map<br>print(fruitPrices['orange']); // Output: 20</code></pre>
Content Short
Content View3579
Content Thumb Highlight
Content Thumb
Content Img Altเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Content TagList, Set, Map , Flutter
Content Date(not set)
Active Status1
Sort99999
Meta Titleเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Meta Descเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Meta Keywordเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Og TitleList, Set, Map , Flutter
Og Descเรียนรู้ประเภทตัวแปร List, Set, และ Map ใน Flutter
Status1
Create Date Time2023-03-25 15:42:51
Update Date Time2023-03-25 15:42:51
Create By
Update By