TypeDefinition.mixedUrlAndClassName constructor

TypeDefinition.mixedUrlAndClassName({
  1. required String mixed,
  2. List<TypeDefinition> generics = const [],
  3. required bool nullable,
  4. bool customClass = false,
  5. int? vectorDimension,
})

Creates an TypeDefinition from mixed where the url and className is separated by ':'.

Implementation

factory TypeDefinition.mixedUrlAndClassName({
  required String mixed,
  List<TypeDefinition> generics = const [],
  required bool nullable,
  bool customClass = false,
  d.int? vectorDimension,
}) {
  var parts = mixed.split(':');
  var classname = parts.last;
  var url = mixed != 'ByteData'
      ? (parts..removeLast()).join(':')
      : 'dart:typed_data';

  return TypeDefinition(
    className: classname,
    nullable: nullable,
    generics: generics,
    url: url.isNotEmpty ? url : null,
    customClass: customClass,
    vectorDimension: vectorDimension,
  );
}