Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@
## 2026-08-28 - Dart Collection For Loops over .map().toList()
**Learning:** In Dart, chaining `.map().toList()` when parsing collections like Firestore query snapshots creates an intermediate `MappedIterable` and closure object, which increases heap allocation and garbage collection pressure.
**Action:** Use a collection `for` loop (e.g., `[for (final doc in snapshot.docs) Model.fromFirestore(doc)]`) to directly construct the list and avoid unnecessary object allocation.

## 2026-09-02 - Flutter Iterable Chaining Performance
**Learning:** In Flutter, chaining iterable methods like `.take(n)` or `.indexed` within widget `build` methods allocates intermediate iterable objects on every rebuild, unnecessarily increasing garbage collection pressure.
**Action:** Replace chained iterable methods in widget `build` methods with explicit collection `for` loops or standard aggregation loops to prevent unnecessary object allocation.
Comment on lines +48 to +50
5 changes: 4 additions & 1 deletion lib/services/course_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import '../models/course.dart';

class CourseService {
final FirebaseFirestore _db = FirebaseFirestore.instance;
final FirebaseFirestore _db;

CourseService({FirebaseFirestore? db})
: _db = db ?? FirebaseFirestore.instance;
Comment on lines +5 to +8

// Optimization: Added optional limit parameter to prevent unbounded reads
Future<List<Course>> getRecommendedCourses({int? limit}) async {
Expand Down
8 changes: 5 additions & 3 deletions lib/views/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,13 @@ class _HomeViewState extends State<HomeView> {

Widget _buildVideoList() {
return Column(
// ⚑ Bolt: Optimize mapping with .indexed for better list generation performance
// ⚑ Bolt: Replaced .take(5).indexed with an explicit for loop to avoid intermediate iterable allocations during rebuilds.
children: [
for (final (index, video) in _videos.take(5).indexed)
for (var index = 0;
index < (_videos.length < 5 ? _videos.length : 5);
index++)
_buildVideoCard(
video,
_videos[index],
AppTheme.cardGradients[index % AppTheme.cardGradients.length],
),
],
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
url: "https://pub.dev"
source: hosted
version: "0.12.19"
version: "0.12.18"
material_color_utilities:
dependency: transitive
description:
Expand Down Expand Up @@ -713,10 +713,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
url: "https://pub.dev"
source: hosted
version: "0.7.10"
version: "0.7.9"
typed_data:
dependency: transitive
description:
Expand Down