fix: card - #523
Conversation
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
|
| if (_wasExpanded && !expanded) { | ||
| _scrollController?.jumpTo(0); | ||
| } | ||
| _wasExpanded = expanded; |
There was a problem hiding this comment.
[other · medium]
_scrollController 是在 DraggableScrollableSheet 的 builder 執行時才被賦值,但在 onNotification 回調中會被使用。這存在生命週期上的風險:如果在 builder 尚未執行、或 Widget 正在銷毀/重建的階段,調用 _scrollController?.jumpTo(0),可能會因為 scrollController 為 null 或處於不穩定狀態而引發異常,或與 DraggableScrollableSheet 的內部滾動邏輯產生衝突。建議在調用前確保 _scrollController 已正確初始化且可控。
| final revealProgress = | ||
| ((extent - _ReportSheet.peek) / | ||
| (_ReportSheet._expanded - _ReportSheet.peek)) | ||
| .clamp(0.0, 1.0); |
There was a problem hiding this comment.
[other · low]
revealProgress 的計算公式 ((extent - _ReportSheet.peek) / (_ReportSheet._expanded - _ReportSheet.peek)) 若分母為零(即 _expanded 等於 peek),會導致除以零的數學錯誤。雖然目前常量定義中 _expanded (1.0) 與 peek (0.32) 不相等,但為了代碼的健壯性,建議增加分母檢查或使用更安全的計算方式。
Suggestion:
| final revealProgress = | |
| ((extent - _ReportSheet.peek) / | |
| (_ReportSheet._expanded - _ReportSheet.peek)) | |
| .clamp(0.0, 1.0); | |
| final revealProgress = ( | |
| (_ReportSheet._expanded - _ReportSheet.peek) > 0 | |
| ? (extent - _ReportSheet.peek) / (_ReportSheet._expanded - _ReportSheet.peek) | |
| : 0.0 | |
| ).clamp(0.0, 1.0); |
| Stack( | ||
| alignment: Alignment.topCenter, | ||
| children: [ | ||
| Opacity( | ||
| opacity: revealProgress, | ||
| child: IgnorePointer( | ||
| ignoring: !expanded, | ||
| child: _expandedContent(context, report), | ||
| ), | ||
| ), | ||
| if (peekOpacity > 0) | ||
| Opacity( | ||
| opacity: peekOpacity, | ||
| child: IgnorePointer( | ||
| ignoring: expanded, | ||
| child: _peekContent(context, report), | ||
| ), | ||
| ), | ||
| ], | ||
| ), |
There was a problem hiding this comment.
[other · medium]
在 Stack 中同時渲染 _expandedContent 與 _peekContent 並進行透明度過渡,若內容包含複雜組件(例如 _ReportImageCard 中的圖片),在拖動過程中可能會因為同時對兩個複雜的 Widget Tree 進行重繪與透明度計算,而造成高負載,導致動畫掉幀(jank)。建議評估組件複雜度,或考慮是否能優化渲染路徑。
修復:
地震報告 UI 顯示的排版問題