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