getStaticMpa static method
获取静态变量的值
Implementation
static String? getStaticMpa(String? content, String key) {
if (content == null) return null;
final regex = RegExp(r'static (\w+) (\w+) = (.*?);');
final matches = regex.allMatches(content);
for (var match in matches) {
final variable = match.group(2);
final value = match.group(3);
if (variable == key) {
if (value!.startsWith('"') && value.endsWith('"')) {
return value.substring(1, value.length - 1);
} else if (value.startsWith("'") && value.endsWith("'")) {
return value.substring(1, value.length - 1);
}
return value;
}
}
return null;
}