fromString static method

Request? fromString(
  1. String data
)

Return a request parsed from the given data, or null if the data is not a valid json representation of a request. The data is expected to have the following format:

{ 'clientRequestTime': millisecondsSinceEpoch 'id': String, 'method': methodName, 'params': { parameter_name: value } }

where both the parameters and clientRequestTime are optional.

The parameters can contain any number of name/value pairs. The clientRequestTime must be an int representing the time at which the client issued the request (milliseconds since epoch).

Implementation

static Request? fromString(String data) {
  try {
    var result = json.decode(data);
    if (result is Map<String, Object?>) {
      return Request.fromJson(result);
    }
    return null;
  } catch (exception) {
    return null;
  }
}