InvokeMethod1_ function

String InvokeMethod1_(
  1. String params
)

Implementation

String InvokeMethod1_(String params) {
  Pointer<Char> result =
      _bindings.InvokeStrMethod(params.toNativeUtf8().cast());
  if (result == nullptr) {
    return "";
  }
  final str = result.cast<Utf8>().toDartString();
  malloc.free(result);
  try {
    final Map<String, dynamic> jsonMap = jsonDecode(str);
    final code = jsonMap['code'];
    if (code != 0) {
      final message = jsonMap['error'] ?? 'Unknown error';
      print('InvokeMethod1_ failed: $message (code: $code)');
      return "";
    }
    jsonMap.remove('code');
    jsonMap.remove('error');
    return jsonEncode(jsonMap);
  } catch (e) {
    return str;
  }
}