createInstance static method
dynamic
createInstance(])
Implementation
static dynamic createInstance(Type? type,
[Symbol? constructor,
List? arguments,
Map<Symbol, dynamic>? namedArguments]) {
if (type == null) {
throw ArgumentError("type: $type");
}
final typeMirror = reflectType(type);
if (typeMirror is ClassMirror) {
return typeMirror
.newInstance(constructor ?? const Symbol(""), arguments ?? const [],
namedArguments ?? {})
.reflectee;
} else {
throw ArgumentError("Cannot create the instance of the type '$type'.");
}
}