toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
switch (code) {
case 100:
return '''
LeetCodeException: Username not initialized.
context
Try LeetCodeAPI.initializeApp("username")
void main() {
runApp(const MyApp());
LeetCodeAPI.initializeApp("username");
}
''';
case 101:
return 'LeetCodeAPIException: User not Found';
case 102:
return 'LeetCodeAPIException: Error code 3 occurred';
default:
return 'LeetCodeAPIException: Unknown error occurred';
}
}