Search code examples
dartaqueduct

Bad state: type '_SpecialTypeMirror' is not a subtype of type 'ClassMirror' in type cast


I'm trying to run the aqueduct's command to generate the DB.

aqueduct db generate

but I always receive this error:

Bad state: type '_SpecialTypeMirror' is not a subtype of type 'ClassMirror' in type cast

I'm using the model like this: import 'package:aqueduct/aqueduct.dart'; import 'package:controle_rural_api/models/Farm.dart';

class User extends ManagedObject implements _User{}

class _User {

  @primaryKey
  int id;
  String otherThings;
  bool active;

  ManagedSet<Farm> farms;
}

That is the complete error:

*** Uncaught error
    Bad state: type '_SpecialTypeMirror' is not a subtype of type 'ClassMirror' in type cast
  **** Stacktrace
  * #0      EntityBuilder._getTableDefinitionForType (package:aqueduct/src/db/managed/builders/entity_builder.dart:236:16)
  * #1      new EntityBuilder (package:aqueduct/src/db/managed/builders/entity_builder.dart:16:31)
  * #2      new DataModelBuilder.<anonymous closure> (package:aqueduct/src/db/managed/builders/data_model_builder.dart:7:42)
  * #3      MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
  * #4      ListIterable.toList (dart:_internal/iterable.dart:219:19)
  * #5      new DataModelBuilder (package:aqueduct/src/db/managed/builders/data_model_builder.dart:7:71)
  * #6      new ManagedDataModel.fromCurrentMirrorSystem (package:aqueduct/src/db/managed/data_model.dart:46:9)
  * #7      MigrationBuilderExecutable.execute (<data:application/dart>:13:557)
  * <asynchronous suspension>
  * #8      main (<data:application/dart>:9:35)
  * <asynchronous suspension>
  * #9      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:296:32)
  * #10     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
  ****

Don't look be anything about my code, but I can't generate the code, What can be?


Solution

  • I found the error. Was in the generics.

    In the class User extends ManagedObject implements _User{} I forgot the type, so should be like this: class User extends ManagedObject<_User> implements _User{}