toString method

  1. @override
String toString()
override

Returns a JSON string representation of this model.

This method uses toJson to serialize the model and then encodes it as a JSON string using jsonEncode. Useful for logging, debugging, or when you need a string representation of the model.

Returns: A JSON-encoded string representation of the model.

Example:

print(user.toString()); // '{"name":"John Doe","age":30}'

Implementation

@override
String toString() {
  return jsonEncode(toJson());
}