From 972ef2149c99fd291e28602c45c36613b0fd0214 Mon Sep 17 00:00:00 2001 From: Yijing Huang Date: Sat, 11 Mar 2023 21:15:34 +0800 Subject: [PATCH] fix(appflowy_flutter): fix cover image overflow #1916 (#1952) * fix(appflowy_flutter): fix cover image overflow #1916 * fix(appflowy_flutter): use OverflowBox to fix #1916 * chore: fix misspelling * fix: prevent the image being overstretched --------- Co-authored-by: Lucas.Xu --- .../plugins/cover/cover_node_widget.dart | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart index 5e95b0380c..452b3356ab 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart @@ -194,7 +194,7 @@ class _CoverImageState extends State<_CoverImage> { Widget build(BuildContext context) { return Stack( children: [ - _buildCoverImage(context), + _buildCoverImage(context, widget.editorState), _buildCoverOverlayButtons(context), ], ); @@ -251,7 +251,7 @@ class _CoverImageState extends State<_CoverImage> { ); } - Widget _buildCoverImage(BuildContext context) { + Widget _buildCoverImage(BuildContext context, EditorState editorState) { final screenSize = MediaQuery.of(context).size; const height = 200.0; final Widget coverImage; @@ -281,12 +281,17 @@ class _CoverImageState extends State<_CoverImage> { coverImage = const SizedBox(); // just an empty sizebox break; } - return UnconstrainedBox( - child: Container( - padding: const EdgeInsets.only(bottom: 10), - height: height, - width: screenSize.width, - child: coverImage, +//OverflowBox needs to be wraped by a widget with constraints(or from its parent) first,otherwise it will occur an erorr + return SizedBox( + height: height, + child: OverflowBox( + maxWidth: screenSize.width, + child: Container( + padding: const EdgeInsets.only(bottom: 10), + height: double.infinity, + width: double.infinity, + child: coverImage, + ), ), ); }