GenericTypeParser class

Provides utilities for parsing and analyzing generic type strings in Dart.

Handles complex generic type signatures including nested generics, and provides structured access to the parsed type information.

{@template generic_parser_features}

Key Features

  • Extracts generic type parameters from type strings
  • Handles nested generic types recursively
  • Splits comma-separated generic parameters
  • Resolves base types and their generic arguments
  • Special handling for core collection types

Example Usage

// Parse a simple generic type
final result = GenericTypeParser.parseGenericTypes('List<String>');

// Parse nested generics
final complex = GenericTypeParser.parseGenericTypes('Map<String, List<int>>');

{@endtemplate}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

extractGenericPart(String typeString) String
Extracts the inner generic type parameters from a type string.
isGeneric(String typeString) bool
Determines if a type string contains generic parameters.
isGenericMirror(String typeString) bool
Checks if the given type string is a mirror type to format with generic parameters.
parseGenericTypes(String genericPart) List<GenericTypeParsingResult>
Fully parses a generic type string into structured results.
resolveGenericType(String typeString) GenericTypeParsingResult
Recursively resolves a type string into its components.
shouldCheckGeneric(Type type) bool
Checks if the given type should be checked for generic parameters.
splitGenericParts(String content) List<String>
Splits comma-separated generic parameters while handling nested generics.