Skip to content

Commit b4095d1

Browse files
committed
Refactor _IdeasListWidget to use ListView.builder for improved performance and dynamic item rendering
1 parent 5ae3569 commit b4095d1

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

lib/screens/inspiration_screen.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,26 @@ class _IdeasListWidget extends StatelessWidget {
108108

109109
@override
110110
Widget build(BuildContext context) {
111-
return ListView(
111+
return ListView.builder(
112112
padding: const EdgeInsets.symmetric(vertical: 16),
113-
children: [
114-
// Header text
115-
Padding(
116-
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
117-
child: Text(
118-
strings.inspirationHeader,
119-
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
120-
color: Colors.grey[600],
121-
fontStyle: FontStyle.italic,
113+
itemCount: ideas.length + 1, // +1 for header
114+
itemBuilder: (context, index) {
115+
if (index == 0) {
116+
// Header text
117+
return Padding(
118+
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
119+
child: Text(
120+
strings.inspirationHeader,
121+
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
122+
color: Colors.grey[600],
123+
fontStyle: FontStyle.italic,
124+
),
122125
),
123-
),
124-
),
125-
// Ideas list
126-
...ideas.map((idea) => _IdeaListItem(idea: idea, dotColor: dotColor)),
127-
],
126+
);
127+
}
128+
// Ideas list items
129+
return _IdeaListItem(idea: ideas[index - 1], dotColor: dotColor);
130+
},
128131
);
129132
}
130133
}

0 commit comments

Comments
 (0)