stateParam function

Future<String> stateParam(
  1. String? fp,
  2. String? method,
  3. bool? isApiPath
)

Implementation

Future<String> stateParam(String? fp, String? method, bool? isApiPath) async {
  if (fp == null || method == null) {
    return "()";
  }
  if (isApiPath != null && isApiPath) {
    Map<String, dynamic>? responseType;
    try {
      responseType = await extractMethodResponseTypeWithField(
        fp,
        method,
        "data,body",
      );
      String responseDataType = "dynamic";
      String result = "()";
      responseDataType = responseType['responseDataType'];
      result = "($responseDataType data)";
      if (result == "(void data)") {
        result = "()";
      }
      return result;
    } catch (e) {
      print("Error: $e");
    }
    return "()";
  } else {
    // current statePath;
    Map<String, dynamic>? eResult = jsonDecode(
      extractConstructorParams(fp, method),
    );
    // printInfo("currentstateparam eResult $eResult");
    final params = eResult?["data"]?["constructorParams"] ?? "()";
    // printInfo("fp: $fp, method:$method ,\neResult $params");
    return params;
  }
}