# ListView & GridView (Flutter) > ListView, ListView.builder, GridView, ScrollController, การนำไอเทมกลับมาใช้ใหม่, lazy loading - 25 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Flutter](https://sharpskill.dev/th/technologies/flutter/interview-questions.md) ## 1. ความแตกต่างหลักระหว่าง ListView() และ ListView.builder() ใน Flutter คืออะไร? **คำตอบ** ListView() สร้าง child ทั้งหมดทันที ซึ่งอาจทำให้เกิดปัญหาด้านประสิทธิภาพกับรายการที่ยาว ส่วน ListView.builder() ใช้ lazy loading และสร้าง widget เฉพาะเมื่อปรากฏบนหน้าจอเท่านั้น สำหรับรายการที่มีองค์ประกอบจำนวนมาก แนะนำให้ใช้ ListView.builder() เนื่องจากช่วยเพิ่มประสิทธิภาพหน่วยความจำและประสิทธิภาพการทำงานด้วยการนำ widget นอกหน้าจอกลับมาใช้ใหม่ ## 2. พารามิเตอร์ใดของ ListView.builder() ที่จำเป็นต้องระบุจำนวนองค์ประกอบที่จะแสดง? **คำตอบ** พารามิเตอร์ itemCount จะบอก ListView.builder() ว่ารายการมีองค์ประกอบกี่รายการ หากไม่มีพารามิเตอร์นี้ รายการจะถูกถือว่าไม่มีที่สิ้นสุดและ itemBuilder จะถูกเรียกไปเรื่อย ๆ การกำหนด itemCount ช่วยให้เฟรมเวิร์กรู้ว่าควรหยุดสร้างองค์ประกอบเมื่อใดและแสดงตัวบ่งชี้การเลื่อนได้อย่างถูกต้อง ## 3. จะเพิ่มตัวคั่นระหว่างแต่ละองค์ประกอบของ ListView ได้อย่างไร? **คำตอบ** ListView.separated() ถูกออกแบบมาโดยเฉพาะเพื่อแสดงตัวคั่นระหว่างองค์ประกอบ มันรับ separatorBuilder เพิ่มเติมจาก itemBuilder ทำให้คุณสามารถกำหนด widget ที่กำหนดเอง (เช่น Divider) ระหว่างแต่ละองค์ประกอบได้ วิธีนี้สะอาดกว่าการเพิ่มตัวคั่นด้วยตนเองใน itemBuilder ## มีอีก 22 คำถาม - จะสร้าง ListView แนวนอนใน Flutter ได้อย่างไร? - พารามิเตอร์ shrinkWrap มีบทบาทอย่างไรใน ListView? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Flutter อื่นๆ - [พื้นฐาน Dart](https://sharpskill.dev/th/technologies/flutter/interview-questions/dart-basics.md): 25 คำถาม, Junior - [พื้นฐานภาษา Dart](https://sharpskill.dev/th/technologies/flutter/interview-questions/dart-language-essentials.md): 15 คำถาม, Junior - [พื้นฐาน Flutter](https://sharpskill.dev/th/technologies/flutter/interview-questions/flutter-fundamentals.md): 18 คำถาม, Junior - [วงจรชีวิตของ Widget](https://sharpskill.dev/th/technologies/flutter/interview-questions/widget-lifecycle.md): 20 คำถาม, Junior - [การจัดเก็บข้อมูลในเครื่อง](https://sharpskill.dev/th/technologies/flutter/interview-questions/local-storage.md): 20 คำถาม, Junior - [วงจรชีวิตของแอปพลิเคชัน](https://sharpskill.dev/th/technologies/flutter/interview-questions/app-lifecycle.md): 20 คำถาม, Junior - [Layouts & Constraints](https://sharpskill.dev/th/technologies/flutter/interview-questions/layouts-constraints.md): 24 คำถาม, Mid-Level - [การนำทางและ Routing](https://sharpskill.dev/th/technologies/flutter/interview-questions/navigation-routing.md): 22 คำถาม, Mid-Level - [การจัดการ State พื้นฐาน](https://sharpskill.dev/th/technologies/flutter/interview-questions/state-management-basics.md): 22 คำถาม, Mid-Level - [Provider Pattern](https://sharpskill.dev/th/technologies/flutter/interview-questions/provider-pattern.md): 18 คำถาม, Mid-Level - [Networking & HTTP](https://sharpskill.dev/th/technologies/flutter/interview-questions/networking-http.md): 20 คำถาม, Mid-Level - [การซีเรียลไลซ์ JSON](https://sharpskill.dev/th/technologies/flutter/interview-questions/json-serialization.md): 20 คำถาม, Mid-Level - [ฐานข้อมูลในเครื่อง](https://sharpskill.dev/th/technologies/flutter/interview-questions/local-database.md): 22 คำถาม, Mid-Level - [ฟอร์มและการตรวจสอบความถูกต้อง](https://sharpskill.dev/th/technologies/flutter/interview-questions/forms-validation.md): 20 คำถาม, Mid-Level - [แอนิเมชัน](https://sharpskill.dev/th/technologies/flutter/interview-questions/animations.md): 20 คำถาม, Mid-Level - [การผสานรวม Firebase](https://sharpskill.dev/th/technologies/flutter/interview-questions/firebase-integration.md): 18 คำถาม, Mid-Level - [การทดสอบยูนิต](https://sharpskill.dev/th/technologies/flutter/interview-questions/unit-testing.md): 20 คำถาม, Mid-Level - [การทดสอบ widget](https://sharpskill.dev/th/technologies/flutter/interview-questions/widget-testing.md): 18 คำถาม, Mid-Level - [การ Build และ Deploy](https://sharpskill.dev/th/technologies/flutter/interview-questions/build-deployment.md): 16 คำถาม, Mid-Level - [การจัดการแพ็กเกจ](https://sharpskill.dev/th/technologies/flutter/interview-questions/package-management.md): 16 คำถาม, Mid-Level - [หน่วยความจำและประสิทธิภาพ](https://sharpskill.dev/th/technologies/flutter/interview-questions/memory-performance.md): 22 คำถาม, Senior - [Streams & RxDart](https://sharpskill.dev/th/technologies/flutter/interview-questions/streams-rxdart.md): 24 คำถาม, Senior - [State Management ขั้นสูง](https://sharpskill.dev/th/technologies/flutter/interview-questions/advanced-state-management.md): 26 คำถาม, Senior - [Flutter Design Patterns](https://sharpskill.dev/th/technologies/flutter/interview-questions/flutter-design-patterns.md): 24 คำถาม, Senior - [การเพิ่มประสิทธิภาพการทำงาน](https://sharpskill.dev/th/technologies/flutter/interview-questions/performance-optimization.md): 26 คำถาม, Senior - [Platform Channels](https://sharpskill.dev/th/technologies/flutter/interview-questions/platform-channels.md): 20 คำถาม, Senior - [Custom Painting](https://sharpskill.dev/th/technologies/flutter/interview-questions/custom-painting.md): 22 คำถาม, Senior - [สถาปัตยกรรมแอปพลิเคชัน Flutter](https://sharpskill.dev/th/technologies/flutter/interview-questions/flutter-app-architecture.md): 22 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/flutter/interview-questions/listview-gridview