Skip to content

Instantly share code, notes, and snippets.

@flutterdevrelgists
Forked from kwalrath/main.dart
Created November 5, 2022 04:01
Show Gist options
  • Save flutterdevrelgists/7c8101e3e59bd6d97200f6b34f9eaeb3 to your computer and use it in GitHub Desktop.
Save flutterdevrelgists/7c8101e3e59bd6d97200f6b34f9eaeb3 to your computer and use it in GitHub Desktop.
Java-to-Dart codelab: Starting Shapes example

Java-to-Dart codelab: Starting Shapes example

Created with <3 with dartpad.dev.

import 'dart:math';
abstract class Shape {
num get area;
}
class Circle implements Shape {
final num radius;
Circle(this.radius);
@override
num get area => pi * pow(radius, 2);
}
class Square implements Shape {
final num side;
Square(this.side);
@override
num get area => pow(side, 2);
}
main() {
final circle = Circle(2);
final square = Square(2);
print(circle.area);
print(square.area);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment