argsString property

String? get argsString

Gets the full argument string from a command message.

Returns the text after the command as a single string, or null if no arguments. The result is cached after the first access for better performance.

Example: "/start hello world" returns "hello world"

Implementation

String? get argsString {
  if (!_argsStringCached) {
    if (!hasCommand) {
      _cachedArgsString = null;
    } else {
      final messageText = text!;
      final firstEntity = entities!.first;
      final commandLength = firstEntity.length;

      if (commandLength >= messageText.length) {
        _cachedArgsString = null;
      } else {
        final argsText = messageText.substring(commandLength).trim();
        _cachedArgsString = argsText.isEmpty ? null : argsText;
      }
    }
    _argsStringCached = true;
  }
  return _cachedArgsString;
}