newInstance abstract method

Object newInstance(
  1. String constructorName,
  2. List positionalArguments, [
  3. Map<Symbol, dynamic> namedArguments
])

Invokes the named constructor and returns the result.

Let c be the class reflected by this mirror let a1, ..., an be the elements of positionalArguments let k1, ..., km be the identifiers denoted by the elements of namedArguments.keys and let v1, ..., vm be the elements of namedArguments.values. If constructorName was created from the empty string Then this method will execute the instance creation expression new c(a1, ..., an, k1: v1, ..., km: vm) in a scope that has access to the private members of c. Otherwise, let f be the simple name of the constructor denoted by constructorName Then this method will execute the instance creation expression new c.f(a1, ..., an, k1: v1, ..., km: vm) in a scope that has access to the private members of c. In either case: If the expression evaluates to a result r, this method returns the result r. If evaluating the expression causes a compilation error the effect is the same as if a non-reflective compilation error had been encountered. If evaluating the expression throws an exception e (that it does not catch) this method throws e.

Note that the return type of the corresponding method in dart:mirrors is InstanceMirror.

Required capabilities: newInstance requires a matching NewInstanceCapability or NewInstanceMetaCapability.

Implementation

//
// TODO(eernst) doc: make this comment more user friendly.
// TODO(eernst) doc: revise language on private members when semantics known.
///
/// Required capabilities: [newInstance] requires a matching
/// [NewInstanceCapability] or [NewInstanceMetaCapability].
Object newInstance(String constructorName, List positionalArguments,
    [Map<Symbol, dynamic> namedArguments]);