generateUserData static method

String generateUserData()

Implementation

static String generateUserData() {
  String trace = StackTrace.current.toString();
  RegExp exp = RegExp(r'RoomEngineNative.[a-zA-Z_0-9]+\s');
  Iterable<Match> matches = exp.allMatches(trace);
  String apiName = "";
  String userdata = "";
  for (final Match m in matches) {
    String match = m[0]!;
    if (match.isNotEmpty) {
      apiName = match.replaceAll("RoomEngineNative.", "").replaceAll(" ", "");
      break;
    }
  }

  if (apiName.isNotEmpty) {
    int now = DateTime.now().microsecondsSinceEpoch;
    userdata = "$apiName-$now";
  } else {
    throw "get userData error trace: $trace";
  }
  return userdata;
}