Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[google_maps_flutter] Convert plugin class to Swift#10545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
stuartmorgan-g wants to merge2 commits intoflutter:main
base:main
Choose a base branch
Loading
fromstuartmorgan-g:maps-swift-initial-structure

Conversation

@stuartmorgan-g
Copy link
Collaborator

Converts the top-level plugin class and its supporting platform view factory from Objective-C to Swift. This changes very little implementation, but lays the groundwork for future incremental conversions.

Part offlutter/flutter#119108

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.23

Converts the top-level plugin class and its supporting platform viewfactory from Objective-C to Swift. This changes very littleimplementation, but lays the groundwork for future incrementalconversions.Part offlutter/flutter#119108
Copy link

@gemini-code-assistgemini-code-assistbot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully converts the top-level plugin class and its associated platform view factory from Objective-C to Swift. The changes are well-contained and include necessary updates to the podspec, module definitions, and test files to support the new Swift implementation. The core logic, including the handling of sharedGMSServices, is correctly preserved.

My review includes one suggestion to improve the robustness of the new Swift code by replacing force-unwrapping and force-casting withguard statements. This will make the plugin more resilient to unexpected inputs and prevent potential crashes.

Comment on lines 30 to 36
// Precache shared map services, if needed. Initializing this prepares GMSServices
// on a background thread controlled by the GoogleMaps framework.
letmapServices=GoogleMapFactory.sharedMapServices

returnFLTGoogleMapController(
frame: frame, viewIdentifier: viewId,
creationParameters: argsas!FGMPlatformMapViewCreationParams, registrar: registrar!)

Choose a reason for hiding this comment

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

high

The use of force casting (as!) and force unwrapping (!) can make the app crash if the assumptions aboutargs type orregistrar being non-nil are violated. It's safer to useguard let with conditional casting (as?) and optional binding to validate these before use. This provides more robust error handling and clearer failure messages if something goes wrong, which is especially useful for plugin consumers.

Also, using_ = ... is more idiomatic for calling something for its side effects while ignoring the result, which avoids an 'unused variable' warning.

    // Precache shared map services, if needed. Initializing this prepares GMSServices    // on a background thread controlled by the GoogleMaps framework.    _=GoogleMapFactory.sharedMapServicesguardlet creationParams= argsas?FGMPlatformMapViewCreationParamselse{      // This is a programmer error on the Dart side, so crashing is reasonable.fatalError("Invalid creation parameters for Google Map:\(String(describing: args))")}guardlet registrar=self.registrarelse{      // This should not happen in a normal lifecycle.fatalError("Registrar is nil when creating Google Map.")}return FLTGoogleMapController(      frame: frame, viewIdentifier: viewId,      creationParameters: creationParams, registrar: registrar)

XCTAssertEqual(mapView.frameObserverCount,0);
}

- (void)testMapsServiceSync {
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

This test is removed because it was testing thatthis code and its supported declarations were all wired up correctly, and in Swift having a lazy type (class-level) variable is a built-in language feature and all of that code is justthis line now, so there's nothing meaningful to test now.

@stuartmorgan-gstuartmorgan-g marked this pull request as draftDecember 2, 2025 12:50
@stuartmorgan-g
Copy link
CollaboratorAuthor

Well, this is fun. We appear to have a SwiftPM-style problem with CocoaPods as well if we adopt any Swift in the target:

Swift Compiler Error (Xcode): Compiling for iOS 14.0, but module 'GoogleMapsUtils' has a minimum deployment target of iOS 15.0:

It goes away if I change the podspec'ss.platform = :ios, '14.0' tos.platform = :ios, '15.0', even though this is compiling the iOS 15 example app and thus shouldn't actually be compiling anything for iOS 14 regardless.

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

Reviewers

@vashworthvashworthAwaiting requested review from vashworthvashworth is a code owner

@LongCatIsLooongLongCatIsLooongAwaiting requested review from LongCatIsLooongLongCatIsLooong will be requested when the pull request is marked ready for reviewLongCatIsLooong is a code owner

1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@stuartmorgan-g

[8]ページ先頭

©2009-2025 Movatter.jp