isCanonical abstract method

bool isCanonical()

Checks if the display name matches the canonical name.

Returns:

  • true if getName and getCanonicalName return identical values
  • false if they differ (e.g., simplified vs complete generic names)

Purpose

Determines whether the class name includes complete generic information or uses a simplified representation. This is important for:

  • Type resolution accuracy
  • Generic parameter preservation
  • Cache key consistency

Example

final listClass = Class.forType<List<String>>();
if (!listClass.isCanonical()) {
  // Use getCanonicalName() for precise type information
  final fullName = listClass.getCanonicalName();
}

Implementation Note

Normally, getName can return simplified names for display purposes, while getCanonicalName preserves complete generic specifications. This method helps determine which name format is being used.

Implementation

bool isCanonical();