You can do something like
library x; import 'dart:mirrors'; abstract class MyAbstract { void doSomething(); } class MyConcrete{ } void main(List<String> args) { print('MyAbstract: ${isAbstract(MyAbstract)}'); print('MyConcrete: ${isAbstract(MyConcrete)}'); } bool isAbstract(Type t) { ClassMirror cm = reflectClass(t); if(cm.declarations.values.firstWhere( (MethodMirror mm) => mm.isAbstract == true, orElse: () => null) != null) { return true; } try { InstanceMirror i = cm.newInstance(new Symbol(''), []); } catch(e) { return (e is AbstractClassInstantiationError); } return false; }
the newInstance part should be expanded to check if there is a default constructor and try using named constructors.
AFAIR has recently had a discussion if it is allowed to instantiate an abstract class (with respect to dependency injection), if that changes the method above it probably doesn't work anymore, but I can't find anything in this question.
Also run this function request: Add a class abstraction verification method
source share