genJoinJsMethod method
生成加入js方法
method
js方法带参数不带返回类型
returnValue
js方法返回值
Implementation
String genJoinJsMethod(List<String> bridgeNames, {required String method, dynamic returnValue}) {
var hasMatch = new RegExp("[(](.*)[)]").hasMatch(method);
if (!hasMatch) {
return "";
}
dynamic value;
var type = returnValue.runtimeType.toString().toLowerCase();
if (type == "bool" || type == "int" || type == "double") {
value = returnValue;
} else {
value = '"$returnValue"';
}
var filter = new RegExp("[(](.*)[)]").firstMatch(method);
var group = filter?.group(0);
if (group.isEmptyString) {
return "";
}
var _method = method.replaceAll(group!, "");
var buffer = new StringBuffer('joinJsMethod9794([');
bridgeNames.forEach((String bridge) {});
for (int i = 0; i < bridgeNames.length; i++) {
buffer.write("'${bridgeNames[i]}'");
if ((i + 1) < bridgeNames.length) {
buffer.write(",");
}
}
buffer.write("], '$_method', function $group { return $value; });");
return buffer.toString();
}