From de57e7358c3292ddbe3e9e7b6ba836e9360a8eda Mon Sep 17 00:00:00 2001 From: Affan Shaikhsurab <51104750+AffanShaikhsurab@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:28:17 +0530 Subject: [PATCH 1/5] Update platform_specific_instructions.md Add explanations for platform-specific code to improve clarity for newcomers by detailing why the changes are necessary --- .../platform_specific_instructions.md | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/doc/dev_guide/platform_specific_instructions.md b/doc/dev_guide/platform_specific_instructions.md index eaf56b98..9245b30c 100644 --- a/doc/dev_guide/platform_specific_instructions.md +++ b/doc/dev_guide/platform_specific_instructions.md @@ -14,6 +14,10 @@ Add below keys to `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Rel com.apple.security.files.user-selected.read-write ``` +### Why is this necessary? +macOS uses **App Sandbox** to protect user data and system resources by restricting an app's access to certain capabilities. These entitlements explicitly grant your app the necessary permissions to: +- Establish network connections (both as a client and server). +- Access files in the user's Downloads folder and files selected by the user. If not added, you can encounter a network connection error similar to the following while running your Flutter app on macOS: @@ -38,9 +42,36 @@ android { } } ``` +### Why is this necessary? +Android apps can encounter a **65k method limit** if you have many dependencies or a large app. Enabling `multiDex` allows your app to split into multiple DEX files, ensuring it can load and execute all required methods without any runtime errors. -## Web +For more information on multidex support, you can refer to the Android developer guide on [Configuring Multidex](https://developer.android.com/studio/build/multidex). -Running it on web requires the following modification in the local cached code of `printing` package. +### Web + +If you're building a Flutter app for the web using the `printing` package, you may encounter a build error like: + +``` +Error: A value of type 'JSString' can't be assigned to a variable of type 'String'. +``` + +This happens because `.toJS` is no longer required for converting Dart strings to JavaScript strings in recent Dart versions. + +**Fix:** +Update the `printing_web.dart` file in the `printing` package by removing `.toJS` from: + +```dart +script.innerHTML = + '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}''' + .toJS; +``` + +Change it to: +```dart +script.innerHTML = + '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}'''; +``` + +This fix ensures compatibility with the latest Dart runtime. For more details, refer to [GitHub Issue #1791](https://github.com/DavBfr/dart_pdf/issues/1791). Read more about it here - https://github.com/DavBfr/dart_pdf/issues/1791 From 538af25be3b230baedded5cb9f63710f3b115772 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 14 Jan 2025 09:43:44 +0530 Subject: [PATCH 2/5] Update platform_specific_instructions.md --- doc/dev_guide/platform_specific_instructions.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/dev_guide/platform_specific_instructions.md b/doc/dev_guide/platform_specific_instructions.md index 9245b30c..4616b7cc 100644 --- a/doc/dev_guide/platform_specific_instructions.md +++ b/doc/dev_guide/platform_specific_instructions.md @@ -14,10 +14,6 @@ Add below keys to `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Rel com.apple.security.files.user-selected.read-write ``` -### Why is this necessary? -macOS uses **App Sandbox** to protect user data and system resources by restricting an app's access to certain capabilities. These entitlements explicitly grant your app the necessary permissions to: -- Establish network connections (both as a client and server). -- Access files in the user's Downloads folder and files selected by the user. If not added, you can encounter a network connection error similar to the following while running your Flutter app on macOS: From 7f5d73538c6978860014ef496fd55267dda5501d Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 14 Jan 2025 09:44:23 +0530 Subject: [PATCH 3/5] Update platform_specific_instructions.md --- doc/dev_guide/platform_specific_instructions.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/dev_guide/platform_specific_instructions.md b/doc/dev_guide/platform_specific_instructions.md index 4616b7cc..7752933c 100644 --- a/doc/dev_guide/platform_specific_instructions.md +++ b/doc/dev_guide/platform_specific_instructions.md @@ -38,8 +38,6 @@ android { } } ``` -### Why is this necessary? -Android apps can encounter a **65k method limit** if you have many dependencies or a large app. Enabling `multiDex` allows your app to split into multiple DEX files, ensuring it can load and execute all required methods without any runtime errors. For more information on multidex support, you can refer to the Android developer guide on [Configuring Multidex](https://developer.android.com/studio/build/multidex). From 022ded2a3e6979a0fa7dd456d6f4b113e57293e7 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 14 Jan 2025 09:50:11 +0530 Subject: [PATCH 4/5] Update platform_specific_instructions.md --- doc/dev_guide/platform_specific_instructions.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/dev_guide/platform_specific_instructions.md b/doc/dev_guide/platform_specific_instructions.md index 7752933c..4ee8398b 100644 --- a/doc/dev_guide/platform_specific_instructions.md +++ b/doc/dev_guide/platform_specific_instructions.md @@ -44,16 +44,21 @@ For more information on multidex support, you can refer to the Android developer ### Web -If you're building a Flutter app for the web using the `printing` package, you may encounter a build error like: +If you're building a Flutter app for the web, you may encounter a build error like: ``` -Error: A value of type 'JSString' can't be assigned to a variable of type 'String'. +Launching lib/main.dart on Chrome in debug mode... +../../../.pub-cache/hosted/pub.dev/printing-5.13.4/lib/printing_web.dart:218:16: Error: +A value of type 'JSString' can't be assigned to a variable of type 'String'. + .toJS; + ^ +Failed to compile application. ``` This happens because `.toJS` is no longer required for converting Dart strings to JavaScript strings in recent Dart versions. **Fix:** -Update the `printing_web.dart` file in the `printing` package by removing `.toJS` from: +Update the `printing_web.dart` file in the cached `printing` package by removing `.toJS` as done in the PR [here](https://github.com/DavBfr/dart_pdf/pull/1739/files) ```dart script.innerHTML = @@ -67,5 +72,4 @@ script.innerHTML = '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}'''; ``` -This fix ensures compatibility with the latest Dart runtime. For more details, refer to [GitHub Issue #1791](https://github.com/DavBfr/dart_pdf/issues/1791). Read more about it here - https://github.com/DavBfr/dart_pdf/issues/1791 From 1ff6baa8bae3ed9f9d978300d1495cbe28f16498 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 14 Jan 2025 09:50:45 +0530 Subject: [PATCH 5/5] Update platform_specific_instructions.md --- doc/dev_guide/platform_specific_instructions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/dev_guide/platform_specific_instructions.md b/doc/dev_guide/platform_specific_instructions.md index 4ee8398b..32016e06 100644 --- a/doc/dev_guide/platform_specific_instructions.md +++ b/doc/dev_guide/platform_specific_instructions.md @@ -41,8 +41,7 @@ android { For more information on multidex support, you can refer to the Android developer guide on [Configuring Multidex](https://developer.android.com/studio/build/multidex). - -### Web +## Web If you're building a Flutter app for the web, you may encounter a build error like: