setAppLabelToResource static method
Pure transform: replaces the android:label="..." attribute value with
@string/app_name. Exposed for testing. Throws StateError when the
attribute is absent. Idempotent — re-running on an already-wired manifest
returns it unchanged.
Implementation
static String setAppLabelToResource(String manifest) {
final re = RegExp(r'android:label="[^"]*"');
if (!re.hasMatch(manifest)) {
throw StateError(
'Could not find an android:label attribute in AndroidManifest.xml.',
);
}
return manifest.replaceFirst(re, 'android:label="@string/app_name"');
}