| Content ID | 121 |
|---|---|
| Category ID | 3 |
| Writer ID | (not set) |
| User ID | (not set) |
| Lang Mode | th |
| Content Name | การใช้งาน Import Library ในภาษา Dart |
| Content Url | การใช้งาน-Import-Library-ในภาษา-Dart |
| Content Desc | <p data-pm-slice="1 1 []">ในภาษา Dart การใช้งาน Library จะต้อง import เข้ามาก่อนเพื่อใช้งานฟังก์ชันหรือคลาสต่าง ๆ ที่ต้องการใช้งาน สามารถ import Library ได้ทั้งจาก Dart SDK หรือจาก Third-party Library ที่ต้องติดตั้งเพิ่มเติม</p> <p>ตัวอย่างการ import Library ในภาษา Dart ได้แก่</p> <ol> <li> <p>การ import Library จาก Dart SDK</p> </li> </ol> <pre style="padding-left: 40px;"><code>import 'dart:io';void main() { <br> print('Enter your name: '); <br> String name = stdin.readLineSync(); <br> print('Hello, $name!');<br>}</code></pre> <p>ในตัวอย่างด้านบน เราได้ import Library ของ Dart SDK ชื่อ dart:io มาใช้งาน เพื่อใช้งานฟังก์ชัน readLineSync() ซึ่งเป็นฟังก์ชันสำหรับรับข้อมูลจากผู้ใช้ผ่านคีย์บอร์ด</p> <ol start="2"> <li> <p>การ import Library จาก Third-party Library</p> </li> </ol> <pre style="padding-left: 40px;"><code>import 'package:http/http.dart' as http;<br> void main() async { <br> var response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts')); <br> print(response.body);<br>}</code></pre> <p>ในตัวอย่างด้านบน เราได้ import Library ของ Third-party ชื่อ http มาใช้งาน เพื่อส่ง HTTP request ไปยัง <a href="https://jsonplaceholder.typicode.com/posts" target="_blank" rel="noopener noreferrer nofollow">https://jsonplaceholder.typicode.com/posts</a> และแสดงผลลัพธ์ที่ได้รับกลับมา</p> <p>โดยสามารถค้นหา Library ที่ต้องการใช้งานได้ที่ <a href="https://pub.dev/" target="_blank" rel="noopener noreferrer nofollow">https://pub.dev/</a> โดยสามารถดูวิธีการใช้งาน Library แต่ละชนิดได้ในเว็บไซต์เดียวกันด้วย และสามารถติดตั้ง Library โดยใช้คำสั่ง <code>pub get</code> หรือ <code>flutter pub get</code> หากเราใช้ Flutter ในโปรเจคของเรา</p> |
| Content Short | <p>ในภาษา Dart การใช้งาน Library จะต้อง import เข้ามาก่อนเพื่อใช้งานฟังก์ชันหรือคลาสต่าง ๆ ที่ต้องการใช้งาน สามารถ import Library ได้ทั้งจาก Dart SDK หรือจาก Third-party Library</p> |
| Content View | 3549 |
| Content Thumb Highlight | |
| Content Thumb | |
| Content Img Alt | การใช้งาน Import Library ในภาษา Dart |
| Content Tag | Import Library,Dart |
| Content Date | (not set) |
| Active Status | 1 |
| Sort | 99999 |
| Meta Title | การใช้งาน Import Library ในภาษา Dart |
| Meta Desc | ในภาษา Dart การใช้งาน Library จะต้อง import เข้ามาก่อนเพื่อใช้งานฟังก์ชันหรือคลาสต่าง ๆ ที่ต้องการใช้งาน สามารถ import Library ได้ทั้งจาก Dart SDK หรือจาก Third-party Library |
| Meta Keyword | Import Library,Dart |
| Og Title | การใช้งาน Import Library ในภาษา Dart |
| Og Desc | ในภาษา Dart การใช้งาน Library จะต้อง import เข้ามาก่อนเพื่อใช้งานฟังก์ชันหรือคลาสต่าง ๆ ที่ต้องการใช้งาน สามารถ import Library ได้ทั้งจาก Dart SDK หรือจาก Third-party Library |
| Status | 1 |
| Create Date Time | 2023-03-25 11:38:21 |
| Update Date Time | 2023-03-25 11:38:21 |
| Create By | |
| Update By |