Skip to content

Instantly share code, notes, and snippets.

@r100-stack
Created March 10, 2021 22:04
Show Gist options
  • Save r100-stack/fa9daf2f1660bf5f40207b291182098c to your computer and use it in GitHub Desktop.
Save r100-stack/fa9daf2f1660bf5f40207b291182098c to your computer and use it in GitHub Desktop.
Sample code to have Dart object print its fields
class A {
int? i1;
int? i2;
A({this.i1, this.i2});
}
class B {
int? i1;
int? i2;
B({this.i1, this.i2});
toString() {
return 'i1: $i1, i2: $i2';
}
}
void main() {
A a = A(i1: 10, i2: 20);
B b = B(i1: 10, i2: 20);
print(a);
print(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment