fix: dragging the Unsplash cover triggers an assertion error (#5404)

This commit is contained in:
Lucas.Xu 2024-05-27 15:37:05 +08:00 committed by GitHub
parent 083be32fa6
commit cb44a885a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,13 +20,13 @@ import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:flowy_infra/theme_extension.dart';
class PageStyleCoverImage extends StatelessWidget {
PageStyleCoverImage({
@ -257,6 +257,9 @@ class PageStyleCoverImage extends StatelessWidget {
void _showUnsplash(BuildContext context) {
final pageStyleBloc = context.read<DocumentPageStyleBloc>();
final backgroundColor = AFThemeExtension.of(context).background;
final maxHeight = MediaQuery.of(context).size.height * 0.6;
context.pop();
showMobileBottomSheet(
@ -267,7 +270,7 @@ class PageStyleCoverImage extends StatelessWidget {
showHeader: true,
showRemoveButton: true,
title: LocaleKeys.pageStyle_unsplash.tr(),
backgroundColor: AFThemeExtension.of(context).background,
backgroundColor: backgroundColor,
onRemove: () {
pageStyleBloc.add(
DocumentPageStyleEvent.updateCoverImage(
@ -278,11 +281,11 @@ class PageStyleCoverImage extends StatelessWidget {
builder: (_) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.6,
maxHeight: maxHeight,
minHeight: 80,
),
child: BlocProvider.value(
value: context.read<DocumentPageStyleBloc>(),
value: pageStyleBloc,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: UnsplashImageWidget(