Skip to content

Commit 972ef21

Browse files
hyj1204LucasXu0
andauthored
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 <[email protected]>
1 parent 668e119 commit 972ef21

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class _CoverImageState extends State<_CoverImage> {
194194
Widget build(BuildContext context) {
195195
return Stack(
196196
children: [
197-
_buildCoverImage(context),
197+
_buildCoverImage(context, widget.editorState),
198198
_buildCoverOverlayButtons(context),
199199
],
200200
);
@@ -251,7 +251,7 @@ class _CoverImageState extends State<_CoverImage> {
251251
);
252252
}
253253

254-
Widget _buildCoverImage(BuildContext context) {
254+
Widget _buildCoverImage(BuildContext context, EditorState editorState) {
255255
final screenSize = MediaQuery.of(context).size;
256256
const height = 200.0;
257257
final Widget coverImage;
@@ -281,12 +281,17 @@ class _CoverImageState extends State<_CoverImage> {
281281
coverImage = const SizedBox(); // just an empty sizebox
282282
break;
283283
}
284-
return UnconstrainedBox(
285-
child: Container(
286-
padding: const EdgeInsets.only(bottom: 10),
287-
height: height,
288-
width: screenSize.width,
289-
child: coverImage,
284+
//OverflowBox needs to be wraped by a widget with constraints(or from its parent) first,otherwise it will occur an erorr
285+
return SizedBox(
286+
height: height,
287+
child: OverflowBox(
288+
maxWidth: screenSize.width,
289+
child: Container(
290+
padding: const EdgeInsets.only(bottom: 10),
291+
height: double.infinity,
292+
width: double.infinity,
293+
child: coverImage,
294+
),
290295
),
291296
);
292297
}

0 commit comments

Comments
 (0)