[flutter_tools][plugins] generated registerWith guards against re-registration (#13384)
This commit is contained in:
@@ -102,10 +102,22 @@ import {{package}}.{{class}};
|
||||
*/
|
||||
public final class GeneratedPluginRegistrant {
|
||||
public static void registerWith(PluginRegistry registry) {
|
||||
if (alreadyRegisteredWith(registry)) {
|
||||
return;
|
||||
}
|
||||
{{#plugins}}
|
||||
{{class}}.registerWith(registry.registrarFor("{{package}}.{{class}}"));
|
||||
{{/plugins}}
|
||||
}
|
||||
|
||||
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
|
||||
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
|
||||
if (registry.hasPlugin(key)) {
|
||||
return true;
|
||||
}
|
||||
registry.registrarFor(key);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user