Milad-Akarie / injectable

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

error after upgrading injectable from 2.3.2 to 2.4.0 #443

Open Alireza-Bodaghi opened 6 months ago

Alireza-Bodaghi commented 6 months ago

i tried to upgrade both the injectable and injectable_generator, but this issue arised. after upgrade: injectable 2.4.0 injectable_generator 2.6.1 flutter 3.16.1

error:

Note: meta is pinned to version 1.11.0 by flutter_test from the flutter SDK. See https://dart.dev/go/sdk-version-pinning for details. Because every version of flutter_test from sdk depends on meta 1.11.0 and injectable >=2.4.0 depends on meta ^1.12.0, flutter_test from sdk is incompatible with injectable >=2.4.0. So, because project depends on both injectable ^2.4.0 and flutter_test from sdk, version solving failed.

i just tried to workaround the above error with this: dependency_overrides: meta: ^1.12.0

the meta problem was solved. but again, i faced the same issue as before with injectable:

Target dart2js failed: ProcessException: Process exited abnormally with exit code 1:
lib/core/utils/injection.config.dart:180:10:
Error: The argument type 'MockLocalDataSource' can't be assigned to the parameter type 'LocalDataSource Function()'.
 - 'MockLocalDataSource' is from 'package:project/core/base/data/base_local_data_source_mocks.dart' ('lib/core/base/data/base_local_data_source_mocks.dart').
 - 'LocalDataSource' is from 'package:project/core/base/data/base_local_data_source.dart' ('lib/core/base/data/base_local_data_source.dart').
    _i49.MockLocalDataSource(),
         ^
lib/core/utils/injection.config.dart:188:43:
Error: The argument type 'AlertHandlerCubit' can't be assigned to the parameter type 'AlertHandlerCubit Function()'.
 - 'AlertHandlerCubit' is from 'package:project/core/utils/alert_handler/alert_handler_cubit.dart' ('lib/core/utils/alert_handler/alert_handler_cubit.dart').
  gh.singleton<_i4.AlertHandlerCubit>(_i4.AlertHandlerCubit());
                                          ^`

i get above error even with injectable 2.3.5. it did not get meta version error. but i got the injection error again. it is only working properly with injectable 2.3.2

is there any solution to this?

erlangparasu commented 6 months ago

is new release tested correctly?

Milad-Akarie commented 6 months ago

@Alireza-Bodaghi meta issue should be fixed in 2.4.1, how to repreduce the other error?

Alireza-Bodaghi commented 5 months ago

after upgrading and running command flutter packages pub run build_runner build, I got this error while building the project:

Because every version of flutter_test from sdk depends on meta 1.9.1 and injectable >=2.4.1 depends on meta 1.11.0, flutter_test from sdk is incompatible with injectable >=2.4.1.
So, because project depends on both injectable ^2.4.1 and flutter_test from sdk, version solving failed.

after struggling over dependencies, I tried upgrading my flutter image to flutter:3.19.2 version. It worked fine then! it only worked with flutter 3.19.2. even on flutter version 3.19.1 i got the above error.