Skip to content

Flutter 3.41 upgrade - #12

Open
xuala69 wants to merge 4 commits into
saeedahmed725:mainfrom
xuala69:flutter-3.41-upgrade
Open

Flutter 3.41 upgrade#12
xuala69 wants to merge 4 commits into
saeedahmed725:mainfrom
xuala69:flutter-3.41-upgrade

Conversation

@xuala69

@xuala69 xuala69 commented Jun 22, 2026

Copy link
Copy Markdown

Fix Pdfrx.getCacheDirectory (Issue) and upgrade to support Flutter 3.41

Summary by Sourcery

Upgrade the package and example app for compatibility with newer Flutter and iOS tooling while fixing PDF cache handling.

New Features:

  • Configure iOS scene manifest and input settings in the example app to align with modern Flutter/iOS app lifecycles.

Bug Fixes:

  • Correct Pdfrx cache directory initialization to use the updated cacheDirectoryPath API and avoid overriding custom asset loaders.

Enhancements:

  • Update Dart SDK, Flutter SDK, and pdfrx dependency constraints to newer versions and bump the package version to 1.0.2.
  • Adjust the page flip controller API to explicitly declare initializeController as returning void.

Build:

  • Add and configure an iOS Podfile and lockfile for the example app using the current Flutter pod helper workflow.
  • Update iOS project settings and plist files in the example app for the latest Flutter iOS embedding, including app delegate changes.

@sourcery-ai

sourcery-ai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

Upgrades the package and example app to be compatible with Flutter 3.41 by updating Pdfrx integration, tightening SDK and Flutter version constraints, modernizing iOS embedding (AppDelegate, Podfile, Info.plist), and making a minor API cleanup in the page flip controller.

Sequence diagram for updated Pdfrx cache and asset initialization in TurnablePdf.initPDFLoaders

sequenceDiagram
  participant App as App
  participant TurnablePdf as TurnablePdf
  participant Directory as Directory
  participant Pdfrx as Pdfrx
  participant RootBundle as rootBundle

  App->>TurnablePdf: initPDFLoaders()
  activate TurnablePdf
  TurnablePdf->>Directory: Directory.systemTemp.path
  TurnablePdf->>Directory: Directory(path: pdfrx_cache)
  TurnablePdf->>Directory: exists()
  alt cacheDir missing
    TurnablePdf->>Directory: create(recursive: true)
  end
  TurnablePdf->>Pdfrx: cacheDirectoryPath ??= cacheDir.path
  TurnablePdf->>Pdfrx: loadAsset ??= (String name) async { ... }
  TurnablePdf->>RootBundle: load(name)
  RootBundle-->>TurnablePdf: ByteData
  TurnablePdf-->>Pdfrx: data.buffer.asUint8List()
  deactivate TurnablePdf
Loading

Sequence diagram for updated iOS AppDelegate implicit engine initialization

sequenceDiagram
  actor User as User
  participant UIApplication as UIApplication
  participant AppDelegate as AppDelegate
  participant EngineBridge as FlutterImplicitEngineBridge
  participant PluginReg as GeneratedPluginRegistrant

  User->>UIApplication: launch app
  UIApplication->>AppDelegate: application(didFinishLaunchingWithOptions:)
  activate AppDelegate
  AppDelegate-->>UIApplication: super.application(...)
  deactivate AppDelegate

  UIApplication->>AppDelegate: didInitializeImplicitFlutterEngine(EngineBridge)
  activate AppDelegate
  AppDelegate->>PluginReg: register(with: EngineBridge.pluginRegistry)
  deactivate AppDelegate
Loading

File-Level Changes

Change Details Files
Update Pdfrx cache handling and asset loading to use the new API surface and avoid overriding existing configuration.
  • Replace Pdfrx.getCacheDirectory initializer with explicit creation of a systemTemp-based cache directory and assignment to Pdfrx.cacheDirectoryPath.
  • Ensure the cache directory is created once and reused via a cached path.
  • Change Pdfrx.loadAsset assignment to use null-aware assignment so user-provided loaders are not overridden.
lib/src/widgets/turnable_pdf.dart
Adjust Dart and Flutter SDK constraints and dependency versions to align with Flutter 3.41 and the latest tooling.
  • Narrow the root package Dart SDK constraint to ">=3.8.0 <4.0.0" and require Flutter ">=3.35.0".
  • Bump turnable_page package version from 1.0.1 to 1.0.2.
  • Upgrade pdfrx dependency from ^2.1.3 to ^2.4.4.
  • Update example app Dart SDK constraint and flutter_lints dev dependency to the latest compatible major version.
pubspec.yaml
example/pubspec.yaml
example/pubspec.lock
Modernize the iOS example project to match current Flutter iOS embedding and configuration requirements.
  • Reorder and extend Info.plist keys to add UIApplicationSceneManifest, scene configuration, and indirect input support while keeping CADisableMinimumFrameDurationOnPhone and related keys configured.
  • Update AppDelegate to conform to FlutterImplicitEngineDelegate, deferring plugin registration to didInitializeImplicitFlutterEngine.
  • Add a standard Flutter iOS Podfile and lockfile and wire up Flutter pods, build configurations, and post_install settings.
  • Remove the explicit MinimumOSVersion from AppFrameworkInfo.plist, letting it be controlled elsewhere.
  • Update Xcode project/workspace and Flutter xcconfig files as generated by the newer Flutter tooling.
example/ios/Runner/Info.plist
example/ios/Runner/AppDelegate.swift
example/ios/Podfile
example/ios/Podfile.lock
example/ios/Flutter/AppFrameworkInfo.plist
example/ios/Flutter/Debug.xcconfig
example/ios/Flutter/Release.xcconfig
example/ios/Runner.xcodeproj/project.pbxproj
example/ios/Runner.xcworkspace/contents.xcworkspacedata
Minor API cleanup in page flip controller to clarify method semantics.
  • Add an explicit void return type to initializeController to match Dart best practices and avoid implicit dynamic.
lib/src/widgets/page_flip_controller.dart

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In TurnablePdf.initPDFLoaders, you always create the pdfrx_cache directory even when Pdfrx.cacheDirectoryPath is already non-null; consider guarding the directory creation with a if (Pdfrx.cacheDirectoryPath == null) check to avoid unnecessary filesystem work.
  • In the new example/ios/Podfile, you might want to uncomment and set platform :ios, '13.0' (or whatever minimum you intend) so the iOS deployment target is explicit and aligned with Flutter 3.41’s requirements instead of relying on CocoaPods’ default.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `TurnablePdf.initPDFLoaders`, you always create the `pdfrx_cache` directory even when `Pdfrx.cacheDirectoryPath` is already non-null; consider guarding the directory creation with a `if (Pdfrx.cacheDirectoryPath == null)` check to avoid unnecessary filesystem work.
- In the new `example/ios/Podfile`, you might want to uncomment and set `platform :ios, '13.0'` (or whatever minimum you intend) so the iOS deployment target is explicit and aligned with Flutter 3.41’s requirements instead of relying on CocoaPods’ default.

## Individual Comments

### Comment 1
<location path="lib/src/widgets/turnable_pdf.dart" line_range="237-243" />
<code_context>
-      }
-      return dir.path;
-    };
+    final cacheDir = Directory(
+      '${Directory.systemTemp.path}${Platform.pathSeparator}pdfrx_cache',
+    );
+    if (!await cacheDir.exists()) {
+      await cacheDir.create(recursive: true);
+    }
+    Pdfrx.cacheDirectoryPath ??= cacheDir.path;

-    Pdfrx.loadAsset = (String name) async {
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid unnecessary filesystem work when `Pdfrx.cacheDirectoryPath` is already configured.

This code creates/checks `cacheDir` on every `initPDFLoaders()` call, even when `Pdfrx.cacheDirectoryPath` is already set by the host. Consider guarding the directory creation with `if (Pdfrx.cacheDirectoryPath == null)` so you only construct `cacheDir` and hit the filesystem when no cache path is preconfigured, reducing unnecessary I/O for consumers who set this upfront.
</issue_to_address>

### Comment 2
<location path="example/ios/Podfile" line_range="1-2" />
<code_context>
+# Uncomment this line to define a global platform for your project
+# platform :ios, '13.0'
+
+# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
</code_context>
<issue_to_address>
**suggestion (bug_risk):** It’s worth uncommenting and aligning the `platform :ios` declaration with Flutter’s minimum iOS version.

With this line commented out, CocoaPods falls back to the Xcode project deployment target, which may now diverge from Flutter’s minimum iOS version (especially since `MinimumOSVersion` was removed from `AppFrameworkInfo.plist`). That mismatch can lead to warnings and subtle build/runtime issues. Please set this `platform :ios` value explicitly to the minimum iOS version required by your Flutter SDK (e.g. `'13.0'` or higher).

```suggestion
# Define a global platform for your project aligned with Flutter's minimum iOS version
platform :ios, '13.0'
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +237 to +243
final cacheDir = Directory(
'${Directory.systemTemp.path}${Platform.pathSeparator}pdfrx_cache',
);
if (!await cacheDir.exists()) {
await cacheDir.create(recursive: true);
}
Pdfrx.cacheDirectoryPath ??= cacheDir.path;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Avoid unnecessary filesystem work when Pdfrx.cacheDirectoryPath is already configured.

This code creates/checks cacheDir on every initPDFLoaders() call, even when Pdfrx.cacheDirectoryPath is already set by the host. Consider guarding the directory creation with if (Pdfrx.cacheDirectoryPath == null) so you only construct cacheDir and hit the filesystem when no cache path is preconfigured, reducing unnecessary I/O for consumers who set this upfront.

Comment thread example/ios/Podfile
Comment on lines +1 to +2
# Uncomment this line to define a global platform for your project
# platform :ios, '13.0'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): It’s worth uncommenting and aligning the platform :ios declaration with Flutter’s minimum iOS version.

With this line commented out, CocoaPods falls back to the Xcode project deployment target, which may now diverge from Flutter’s minimum iOS version (especially since MinimumOSVersion was removed from AppFrameworkInfo.plist). That mismatch can lead to warnings and subtle build/runtime issues. Please set this platform :ios value explicitly to the minimum iOS version required by your Flutter SDK (e.g. '13.0' or higher).

Suggested change
# Uncomment this line to define a global platform for your project
# platform :ios, '13.0'
# Define a global platform for your project aligned with Flutter's minimum iOS version
platform :ios, '13.0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant