tokenizer method

Seed tokenizer(
  1. String verSeed, {
  2. String? rawString,
})

Tokenizes the provided raw seed information, extracting relevant details.

Given a verified seed verSeed and an optional raw string rawString, this method parses and tokenizes the raw information to extract essential details like IP address and port number. If the rawString is null or its length is less than or equal to 5, the method returns the current instance without making any changes.

The expected format of the raw string is assumed to be "ip:port".

Example:

Seed seed = Seed();
seed.tokenizer("122.148.0.3", rawString: "192.168.0.1:8080");
print(seed.ip);   // Output: "192.168.0.1"
print(seed.port); // Output: 8080

Parameters:

  • verSeed: A verified seed string.
  • rawString: An optional raw string containing IP address and port.

Returns: The current instance of the Seed class after tokenization.

Implementation

Seed tokenizer(String verSeed, {String? rawString}) {
  if (rawString == null || rawString.length <= 5) {
    if (verSeed.isEmpty || verSeed.length <= 5) {
      return this;
    } else {
      rawString = verSeed;
    }
  }
  List<String> seedPart = rawString.split(":");
  return copyWith(ip: seedPart[0], port: int.parse(seedPart[1]));
}