import'dart:math';voidmain() {// Abstract Class & Methods// You can't make an instance of an abstract class// Abstract class always meant to extended by some other class// When any class extend an abstract , it must override it's// abstract methodsvar circle1 =Circle(3);var square1 =Square(3);print(circle1.calarea());print(square1.calarea());}abstractclassShape {voidtest() {print("test"); }voiddraw();doublecalarea();}classCircleextendsShape {int radius;final pi =3.14;@overridevoiddraw() {print("Drawing a Circle"); }@overridedoublecalarea() {return (this.pi * this.radius * this.radius); }Circle(this.radius);}classSquareextendsShape {double length;@overridevoiddraw() {print("Drawing a Square"); }@overridedoublecalarea() {returnpow(this.length, 2); }Square(this.length);}
You can't declare an abstract method inside a simple class . You can only declare abstract methods inside abstract class
❌ Complier shows an error
✅ Compiler is happy
You can have an abstract class with only normal methods , but that defeats the purpose of using an abstract class