ListView & GridView
ListView, ListView.builder, GridView, ScrollController, item reuse, lazy loading
1What is the main difference between ListView() and ListView.builder() in Flutter?
What is the main difference between ListView() and ListView.builder() in Flutter?
Risposta
ListView() creates all its children immediately, which can cause performance issues with long lists. ListView.builder() uses lazy loading and only creates widgets when they become visible on screen. For lists with many elements, ListView.builder() is recommended as it optimizes memory and performance by recycling off-screen widgets.
2Which ListView.builder() parameter is required to specify the number of elements to display?
Which ListView.builder() parameter is required to specify the number of elements to display?
Risposta
The itemCount parameter tells ListView.builder() how many elements the list contains. Without this parameter, the list would be considered infinite and itemBuilder would be called indefinitely. Setting itemCount allows the framework to know when to stop building elements and display the scroll indicator correctly.
3How to add a separator between each element of a ListView?
How to add a separator between each element of a ListView?
Risposta
ListView.separated() is specifically designed to display separators between elements. It takes a separatorBuilder in addition to itemBuilder, allowing you to define a custom widget (like a Divider) between each element. This approach is cleaner than manually adding separators in itemBuilder.
How to create a horizontal ListView in Flutter?
What is the role of the shrinkWrap parameter in a ListView?
+22 domande da colloquio
Altri argomenti di colloquio Flutter
Dart Basics
Dart Language Essentials
Flutter Fundamentals
Widget Lifecycle
Local Storage
Application Lifecycle
Layouts & Constraints
Navigation & Routing
Basic State Management
Provider Pattern
Networking & HTTP
JSON Serialization
Local Database
Forms & Validation
Animations
Firebase Integration
Unit Testing
Widget Testing
Build & Deployment
Package Management
Memory & Performance
Streams & RxDart
Advanced State Management
Flutter Design Patterns
Performance Optimization
Platform Channels
Custom Painting
Flutter Application Architecture
Padroneggia Flutter per il tuo prossimo colloquio
Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.
Inizia gratis