Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.
Closed
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
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2025-05-15 - [Optimize HubSection list and DPR lookups]
**Learning:** Providing `itemExtent` to `ListView.builder` for horizontal hubs with uniform items drastically reduces layout overhead. Additionally, using specialized `MediaQuery` selectors like `devicePixelRatioOf(context)` prevents unnecessary global rebuilds on safe area or window size changes.
**Action:** Always check for fixed-size list items and prefer specific MediaQuery selectors over `MediaQuery.of(context)`.
4 changes: 3 additions & 1 deletion lib/utils/plex_image_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class PlexImageHelper {
/// the platform-reported DPR doesn't reflect the true physical density
/// (common on Linux X11 with compositor scaling).
static double effectiveDevicePixelRatio(BuildContext context) {
final reportedDpr = MediaQuery.of(context).devicePixelRatio;
// BOLT OPTIMIZATION: Use specialized MediaQuery selectors to prevent unnecessary rebuilds
// when unrelated MediaQuery properties change (e.g. safe area insets).
final reportedDpr = MediaQuery.devicePixelRatioOf(context);
try {
final displayWidth = View.of(context).display.size.width;
// Scale quality with display resolution: 1920px = baseline (1.0x)
Expand Down
3 changes: 3 additions & 0 deletions lib/widgets/hub_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ class HubSectionState extends State<HubSection> {
builder: (scrollController) => ListView.builder(
controller: scrollController,
scrollDirection: Axis.horizontal,
// BOLT OPTIMIZATION: Use itemExtent to skip child measurement and improve scroll performance.
// All items in this hub have a uniform width of cardWidth + 4px padding.
itemExtent: _itemExtent,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
itemCount: widget.hub.items.length,
itemBuilder: (context, index) {
Expand Down