removeScheme method
Removes a custom URL scheme intent-filter from AndroidManifest.xml. Returns the updated XML content.
Implementation
String removeScheme(String xmlContent, String scheme) {
final doc = XmlReader.parse(xmlContent);
final activity = _findMainActivity(doc);
final filtersToRemove = <XmlNode>[];
for (final child in activity.children) {
if (child is XmlElement && child.name.local == 'intent-filter') {
if (_isCustomSchemeIntentFilter(child, scheme)) {
filtersToRemove.add(child);
}
}
}
if (filtersToRemove.isEmpty) {
return xmlContent;
}
for (final filter in filtersToRemove) {
activity.children.remove(filter);
}
return XmlReader.serialize(doc);
}