pluginUpdateTarget function

int? pluginUpdateTarget(
  1. PluginRef ref,
  2. ManagedComponentMaster master, {
  3. String projectId = '',
  4. String? sdkVersion,
})

The version ref should run now by master, under the managed components' rules: same major (the pin, else the published semver's), the channel's pointer raised by rollouts, newest not blocked that the SDK can run. Null: run PluginRef.version (the published one).

Implementation

int? pluginUpdateTarget(PluginRef ref, ManagedComponentMaster master, {String projectId = '', String? sdkVersion}) {
  final major = ref.pin ?? Semver.tryParse(ref.semver)?.major ?? master.versions[ref.version]?.major;
  if (major == null) return null;
  final target = master.resolve(major: major, channel: ref.channel, projectId: projectId, sdkVersion: sdkVersion);
  if (target == null || target == ref.version) return null;
  if (target > ref.version || master.blocked.contains(ref.version)) return target;
  return null;
}