···
/// - Loading, empty, and error states
/// - Automatic comment loading on screen init
class PostDetailScreen extends StatefulWidget {
40
-
const PostDetailScreen({required this.post, super.key});
40
+
const PostDetailScreen({required this.post, this.isOptimistic = false, super.key});
/// Post to display (passed via route extras)
45
+
/// Whether this is an optimistic post (just created, not yet indexed)
46
+
/// When true, skips initial comment load since we know there are no comments
47
+
final bool isOptimistic;
State<PostDetailScreen> createState() => _PostDetailScreenState();
···
// Listen for changes to trigger rebuilds
_commentsProvider.addListener(_onProviderChanged);
125
-
// Check if we already have cached data
126
-
if (_commentsProvider.comments.isNotEmpty) {
129
+
// Skip loading for optimistic posts (just created, not yet indexed)
130
+
if (widget.isOptimistic) {
132
+
debugPrint('✨ Optimistic post - skipping initial comment load');
134
+
// Don't load comments - there won't be any yet
135
+
} else if (_commentsProvider.comments.isNotEmpty) {
// Already have data - restore scroll position immediately
···
color: AppColors.primary,
controller: _scrollController,
680
+
physics: const AlwaysScrollableScrollPhysics(),
// Floating app bar that hides on scroll down,