Skip to content

Instantly share code, notes, and snippets.

@rena2019
Last active April 4, 2025 09:14
Show Gist options
  • Save rena2019/05ec3bede00f5ec8aca55f772e9d9098 to your computer and use it in GitHub Desktop.
Save rena2019/05ec3bede00f5ec8aca55f772e9d9098 to your computer and use it in GitHub Desktop.
myconstructors.dart
class PointA {
double x = 1.0;
double y = 2.0;
// The implicit default constructor sets these variables to (1.0,2.0)
// PointA();
//
PointA(String s) : x = double.parse(s), y = double.parse(s);
@override
String toString() {
return 'PointA($x, $y)';
}
}
void main() {
PointA point = PointA("1.5");
print(point);
}
// https://gist.github.com/rena2019/05ec3bede00f5ec8aca55f772e9d9098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment