diff --git a/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart b/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart index afd608aa8..4b0073823 100644 --- a/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart +++ b/integration_test/scenarios/email_detailed/deformed_inlined_image_scenario.dart @@ -21,7 +21,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
inline-image-oversize-with-style
inline-image-oversize-with-style-and-width-attribute @@ -45,7 +45,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario {
inline-image-normal-size-with-style-and-width-attribute @@ -105,13 +105,10 @@ class DeformedInlinedImageScenario extends BaseTestScenario { .tap(); expect(emailController, isNotNull); - final webViewController = emailController - ?.htmlContentViewKey - ?.currentState - ?.webViewController; - expect(webViewController, isNotNull); + final htmlContentViewKey = emailController?.htmlContentViewKey; + expect(htmlContentViewKey, isNotNull); - final result = await webViewController?.evaluateJavascript( + final result = await htmlContentViewKey!.currentState!.webViewController.evaluateJavascript( source: ''' (function() { const images = document.querySelectorAll('img'); @@ -144,8 +141,7 @@ class DeformedInlinedImageScenario extends BaseTestScenario { expect(imgWidth, equals('100')); expect(imgHeight, equals('100')); } else if (imgAlt == 'inline-image-normal-size-with-style-and-width-attribute') { - expect(imgStyle.contains('max-width: 100%;'), isFalse); - expect(imgStyle.contains('width: 100px; height: 100px;'), isTrue); + expect(imgStyle.contains('width: 100px;height: 100px;'), isTrue); expect(imgWidth, equals('100')); expect(imgHeight, equals('100')); } else { diff --git a/lib/features/email/presentation/controller/single_email_controller.dart b/lib/features/email/presentation/controller/single_email_controller.dart index f9de811fa..ab7b5c09f 100644 --- a/lib/features/email/presentation/controller/single_email_controller.dart +++ b/lib/features/email/presentation/controller/single_email_controller.dart @@ -195,8 +195,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin { final currentEmailLoaded = Rxn(); final isEmailContentClipped = RxBool(false); final attendanceStatus = Rxn(); + final htmlContentViewKey = GlobalKey(); - GlobalKey? htmlContentViewKey; EmailId? _currentEmailId; Identity? _identitySelected; ButtonState? _printEmailButtonState; @@ -244,9 +244,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin { void onInit() { _registerObxStreamListener(); _listenDownloadAttachmentProgressState(); - if (PlatformInfo.isIntegrationTesting) { - htmlContentViewKey = GlobalKey(); - } super.onInit(); } @@ -254,9 +251,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin { void onClose() { _downloadProgressStateController.close(); _attachmentListScrollController.dispose(); - if (PlatformInfo.isIntegrationTesting) { - htmlContentViewKey = null; - } super.onClose(); } diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index 29d4c642a..d24b324d0 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -447,7 +447,9 @@ class EmailView extends GetWidget { ), child: LayoutBuilder(builder: (context, constraints) { return HtmlContentViewer( - key: controller.htmlContentViewKey, + key: PlatformInfo.isIntegrationTesting + ? controller.htmlContentViewKey + : null, contentHtml: allEmailContents, initialWidth: constraints.maxWidth, direction: AppUtils.getCurrentDirection(context), @@ -487,7 +489,9 @@ class EmailView extends GetWidget { ), child: LayoutBuilder(builder: (context, constraints) { return HtmlContentViewer( - key: controller.htmlContentViewKey, + key: PlatformInfo.isIntegrationTesting + ? controller.htmlContentViewKey + : null, contentHtml: allEmailContents, initialWidth: constraints.maxWidth, direction: AppUtils.getCurrentDirection(context),