fix: image gen during streaming
This commit is contained in:
@@ -570,7 +570,7 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
|
||||
const SizedBox(height: Spacing.md),
|
||||
],
|
||||
|
||||
// Display generated images from files property
|
||||
// Display generated images from files property - OUTSIDE AnimatedSwitcher to prevent fade issues
|
||||
if (widget.message.files != null &&
|
||||
widget.message.files!.isNotEmpty) ...[
|
||||
_buildGeneratedImages(),
|
||||
@@ -785,8 +785,7 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
|
||||
maxWidth: 500,
|
||||
maxHeight: 400,
|
||||
),
|
||||
disableAnimation: widget
|
||||
.isStreaming, // Disable animation during streaming
|
||||
disableAnimation: false, // Keep animations enabled to prevent black display
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -809,8 +808,7 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
|
||||
maxWidth: imageCount == 2 ? 245 : 160,
|
||||
maxHeight: imageCount == 2 ? 245 : 160,
|
||||
),
|
||||
disableAnimation:
|
||||
widget.isStreaming, // Disable animation during streaming
|
||||
disableAnimation: false, // Keep animations enabled to prevent black display
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
@@ -247,22 +247,8 @@ class _EnhancedImageAttachmentState
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context); // Required for AutomaticKeepAliveClientMixin
|
||||
|
||||
// Use a single container with AnimatedSwitcher for smooth transitions
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
switchInCurve: Curves.easeInOut,
|
||||
switchOutCurve: Curves.easeInOut,
|
||||
layoutBuilder: (currentChild, previousChildren) {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: <Widget>[
|
||||
...previousChildren,
|
||||
if (currentChild != null) currentChild,
|
||||
],
|
||||
);
|
||||
},
|
||||
child: _buildContent(),
|
||||
);
|
||||
// Directly return content without AnimatedSwitcher to prevent black flash during streaming
|
||||
return _buildContent();
|
||||
}
|
||||
|
||||
Widget _buildContent() {
|
||||
@@ -286,11 +272,8 @@ class _EnhancedImageAttachmentState
|
||||
imageWidget = _buildBase64Image();
|
||||
}
|
||||
|
||||
// Apply fade animation only when first showing content
|
||||
if (!widget.disableAnimation && _hasShownContent) {
|
||||
return FadeTransition(opacity: _fadeAnimation, child: imageWidget);
|
||||
}
|
||||
|
||||
// Always show the image without fade transitions during streaming to prevent black display
|
||||
// The AutomaticKeepAliveClientMixin and global caching should preserve the image state
|
||||
return imageWidget;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user