Milad-Akarie / injectable

Code Generator for get_it
MIT License
565 stars 143 forks source link

Enum is not a class element #469

Open kevin-ye opened 6 months ago

kevin-ye commented 6 months ago

I am using a dart native Enum as return type in module, the generator is throwing error saying my enum "is not a class element"

pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flutter_mobx: ^2.2.1+1
  get_it: ^7.7.0
  injectable: ^2.4.2
  mobx: ^2.3.3+2
  mobx_codegen: ^2.6.1
  package_info_plus: ^8.0.0
  provider: ^6.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^3.0.0
  injectable_generator: ^2.6.1
  build_runner: ^2.4.10

Module:

Enum PlatformType { android, ios }

@module
abstract class AppModule {
  @Named("currentPlatform")
  PlatformType get currentPlatform {
    if (Platform.isAndroid) {
      return PlatformType.android;
    } else {
      return PlatformType.ios;
    }
  }
}
ChaserVasya commented 5 months ago

same