Skip to content

Add TypeChecker like typeNamed that accepts a String #795

@Rexios80

Description

@Rexios80

TypeChecker.typeNamed takes a Type object but only relies on its toString value. I need to build TypeCheckers for packages that aren’t project dependencies, so having a variant that accepts a type name as a String would be far more practical. I’ve implemented a workaround class, but this really should be supported natively.

The workaround:

/// Create a Type class who's toString() method returns the name
///
/// Workaround for TypeChecker.typeNamed() not accepting a String.
class TypeNamed implements Type {
  /// The name of the type
  final String name;

  /// Constructor
  const TypeNamed(this.name);

  @override
  String toString() => name;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions