-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[path_provider_foundation] Adding support for getContainerPath on iOS #7114
Conversation
|
To add tests for this, I added an App Group to the Apple Developer Flutter team and used that in the example app -- but not sure if that's the best approach :) |
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add tests for this, I added an App Group to the Apple Developer Flutter team and used that in the example app -- but not sure if that's the best approach :)
I think that's okay, @stuartmorgan do you have an opinion?
packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
Outdated
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
Outdated
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
Outdated
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
Outdated
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/lib/path_provider_foundation.dart
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Jenn Magder <[email protected]>
packages/path_provider/path_provider_foundation/lib/path_provider_foundation.dart
Show resolved
Hide resolved
packages/path_provider/path_provider_foundation/lib/path_provider_foundation.dart
Show resolved
Hide resolved
|
|
||
| test('getContainerPath', () async { | ||
| const String appGroupIdentifier = 'group.example.test'; | ||
| if (Platform.isIOS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan is there a suggested way to mock out the platform in these tests? I know how to do it in the flutter_tool but not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It usually doesn't come up here given the ways plugins are structured; I would just write a trivial object-based wrapper around the Platform check and make it injectable in the constructor. (And then move the PathProviderFoundation construction out of setUp, which is something I general prefer anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what that means? 🙈 Constructor for what, the PathProviderFoundation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly; it would look like this, with the parameter being some little class you define (e.g., PathProviderPlatformProvider) that is itself @visibleForTesting. The Platform call would move into that helper class, so you could inject a FakePathProviderPlatformProvider in tests that gives whatever answer the test case requires.
|
We've just completed the migration of the plugin code to the flutter/packages repository, as described in https://flutter.dev/go/flutter-plugins-repo-migration, and this repository is now being archived. Unfortunately that means that all in-progress PRs here must be moved to flutter/packages. Please see our instructions for an explanation of how to move your PR, and if you have any issues moving your PR please don't hesitate to reach out in the #hackers-ecosystem channel in Discord. Our apologies that your PR was caught in this one-time transition. We're aware that it's disruptive in the short term, and appreciate your help in getting us to a better long-term state! |
This PR adds a method
getContainerPathin thepath_provider_foundationplugin, which returns the path to the container for a given App Group. It uses thegetContainerUrlAPI.This is only implemented for iOS, since App Groups works a bit differently on macOS.
Issue fixed: flutter/flutter#117685
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].CHANGELOG.mdto add a description of the change, [following repository CHANGELOG style].///).