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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transitive dependencies on multiple implementations of a federated plugin result in no auto-registration #118401
Comments
Did you reproduce this in a new project, or are you updating an existing project? Could you provide the contents of |
same issue |
Sorry, @stuartmorgan for the late response. I encountered this in the existing project while upgrading the package version. Please find the //
// Generated file. Do not edit.
// This file is generated from template in file `flutter_tools/lib/src/flutter_plugins.dart`.
//
// @dart = 2.12
import 'dart:io'; // flutter_ignore: dart_io_import.
import 'package:path_provider_android/path_provider_android.dart';
import 'package:shared_preferences_android/shared_preferences_android.dart';
import 'package:url_launcher_android/url_launcher_android.dart';
import 'package:path_provider_ios/path_provider_ios.dart';
import 'package:url_launcher_ios/url_launcher_ios.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider_linux/path_provider_linux.dart';
import 'package:share_plus/share_plus.dart';
import 'package:shared_preferences_linux/shared_preferences_linux.dart';
import 'package:url_launcher_linux/url_launcher_linux.dart';
import 'package:path_provider_macos/path_provider_macos.dart';
import 'package:shared_preferences_foundation/shared_preferences_foundation.dart';
import 'package:url_launcher_macos/url_launcher_macos.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider_windows/path_provider_windows.dart';
import 'package:share_plus/share_plus.dart';
import 'package:shared_preferences_windows/shared_preferences_windows.dart';
import 'package:url_launcher_windows/url_launcher_windows.dart';
@pragma('vm:entry-point')
class _PluginRegistrant {
@pragma('vm:entry-point')
static void register() {
if (Platform.isAndroid) {
try {
PathProviderAndroid.registerWith();
} catch (err) {
print(
'`path_provider_android` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharedPreferencesAndroid.registerWith();
} catch (err) {
print(
'`shared_preferences_android` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
UrlLauncherAndroid.registerWith();
} catch (err) {
print(
'`url_launcher_android` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
} else if (Platform.isIOS) {
try {
PathProviderIOS.registerWith();
} catch (err) {
print(
'`path_provider_ios` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
UrlLauncherIOS.registerWith();
} catch (err) {
print(
'`url_launcher_ios` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
} else if (Platform.isLinux) {
try {
PackageInfoPlusLinuxPlugin.registerWith();
} catch (err) {
print(
'`package_info_plus` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
PathProviderLinux.registerWith();
} catch (err) {
print(
'`path_provider_linux` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharePlusLinuxPlugin.registerWith();
} catch (err) {
print(
'`share_plus` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharedPreferencesLinux.registerWith();
} catch (err) {
print(
'`shared_preferences_linux` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
UrlLauncherLinux.registerWith();
} catch (err) {
print(
'`url_launcher_linux` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
} else if (Platform.isMacOS) {
try {
PathProviderMacOS.registerWith();
} catch (err) {
print(
'`path_provider_macos` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharedPreferencesFoundation.registerWith();
} catch (err) {
print(
'`shared_preferences_foundation` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
UrlLauncherMacOS.registerWith();
} catch (err) {
print(
'`url_launcher_macos` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
} else if (Platform.isWindows) {
try {
PackageInfoPlusWindowsPlugin.registerWith();
} catch (err) {
print(
'`package_info_plus` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
PathProviderWindows.registerWith();
} catch (err) {
print(
'`path_provider_windows` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharePlusWindowsPlugin.registerWith();
} catch (err) {
print(
'`share_plus` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
SharedPreferencesWindows.registerWith();
} catch (err) {
print(
'`shared_preferences_windows` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
try {
UrlLauncherWindows.registerWith();
} catch (err) {
print(
'`url_launcher_windows` threw an error: $err. '
'The app may not function as expected until you remove this plugin from pubspec.yaml'
);
rethrow;
}
}
}
} |
It's definitely missing. Do you have |
Yes I can see:
|
Thanks, that narrows it down somewhat. What about in It's very odd that you still have |
Yes, it's there in
|
The dependency on I'll need to investigate why having two transitive dependencies implementing the same platform is causing no registration to be output, since that shouldn't happen. In the meantime, until |
This comment was marked as off-topic.
This comment was marked as off-topic.
Fixes issues related to transitive dependencies on plugins with Dart implementations: - Ensures that if there are multiple transitive dependencies including the app-facing-package-selected default, the default is picked. Previously it was order-dependent what would happen, and in some cases no implementation would be picked. - Allows registration of a package's implementation even if the app-facing package is not present, as long as there is only one possible implementation (or the app directly picks one). There are cases where depending on just a platform implementation of a package, rather than the app-facing package, is useful. (E.g., shared_preferences_linux depends directly on path_provider_linux.) Also fixes a bug where an implementation conflict error was being gated behind a flag that was only supposed to be hiding an (overly-strict at the moment) error about plugin pubspec definitions. Fixes flutter#99083 Fixes flutter#118401
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
This is only happening on iOS.
Steps to Reproduce
shared_preferences: 2.0.16
inpubspec.yaml
final prefs = await SharedPreferences.getInstance();
Expected results:
We should get the
SharedPreferences
object.Actual results:
Logs
flutter doctor -v
output:Complete code for reproducing the issue can be found here
The text was updated successfully, but these errors were encountered: