إنشاء قوائم قابلة للتمرير باستخدام ListView
اعرض مجموعات قابلة للتمرير بكفاءة في Flutter باستخدام ListView وListView.builder وفواصل العناصر.
إنشاء قوائم قابلة للتمرير باستخدام ListView درس مجاني في Flutter Mobile Development على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Flutter Mobile Development، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Flutter Mobile Development 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why ListView?
Most apps show lists: messages, products, feeds. A ListView arranges its children in a scrollable column, handling overflow automatically when content exceeds the screen.
A Simple ListView
Pass a fixed set of children. Good for short, known lists.
ListView(
children: [
Text("Apple"),
Text("Banana"),
Text("Cherry"),
],
)ListTile for Rows
ListTile is a ready-made row with leading icon, title, subtitle, and trailing widget, perfect for menus and settings.
ListTile(
leading: Icon(Icons.person),
title: Text("Ada Lovelace"),
subtitle: Text("Mathematician"),
trailing: Icon(Icons.chevron_right),
)The Problem with Long Lists
A plain ListView builds every child up front. For hundreds of items this wastes memory and slows startup. We need lazy building.
ListView.builder
ListView.builder creates items on demand as they scroll into view, so only visible rows exist in memory.
ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(title: Text(items[index]));
},
)itemCount and itemBuilder
itemCount tells Flutter how many rows exist; itemBuilder is called with each index to build that row. Omitting itemCount makes an infinite list.
Adding Separators
ListView.separated inserts a divider widget between items, keeping spacing consistent.
ListView.separated(
itemCount: items.length,
itemBuilder: (c, i) => ListTile(title: Text(items[i])),
separatorBuilder: (c, i) => Divider(),
)Horizontal Lists
Set scrollDirection: Axis.horizontal to scroll sideways, useful for carousels and chip rows.
ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: tags.length,
itemBuilder: (c, i) => Chip(label: Text(tags[i])),
)Lists Inside Columns
A ListView wants unbounded height, which conflicts with a Column. Wrap it in Expanded to give it the remaining space.
Column(
children: [
Text("Header"),
Expanded(
child: ListView.builder(...),
),
],
)Handling Taps
Make rows interactive with onTap on a ListTile or by wrapping items in GestureDetector/InkWell.
ListTile(
title: Text(items[index]),
onTap: () => print("Tapped " + items[index]),
)Putting It Together
Use ListView.builder for performance, ListTile for clean rows, separated for dividers, and wrap in Expanded inside columns.
Quick Check
Test your understanding of Flutter lists.
Recap
You built scrollable lists:
ListViewfor short fixed listsListView.builderfor efficient long listsListTilerows andseparateddividers- Wrap in
Expandedinside aColumn
الأسئلة الشائعة
هل درس «إنشاء قوائم قابلة للتمرير باستخدام ListView» مجاني؟
نعم — نص درس «إنشاء قوائم قابلة للتمرير باستخدام ListView» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Flutter Mobile Development، انتقل إلى CoddyKit PRO. تتضمن دورة Flutter Mobile Development 4 دروس في المجموع.
ماذا ستتعلم في «إنشاء قوائم قابلة للتمرير باستخدام ListView»؟
اعرض مجموعات قابلة للتمرير بكفاءة في Flutter باستخدام ListView وListView.builder وفواصل العناصر. تتمرن على Flutter Mobile Development مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Flutter Mobile Development؟
لا تُشترط خبرة سابقة. Flutter Mobile Development على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «إنشاء قوائم قابلة للتمرير باستخدام ListView»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Flutter Mobile Development هذا؟
نعم. كل درس في Flutter Mobile Development يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- عناصر Stateless مقابل Stateful
- عناصر التخطيط الأساسية
- عناصر واجهة المستخدم التفاعلية
- إنشاء قوائم قابلة للتمرير باستخدام ListView