Something broke in injectable 2.3.5
juskek opened this issue · 3 comments
Something broke in injectable for version 2.3.5
- When I use flutter run, flutter test or flutter build in local with
dart : "3.2.3"
flutter: "3.16.6"
injectable: "2.3.5"
everything works as expected
- But when I use flutter test in my CI, or flutter build in my CD, I get a whole bunch of errors in the autogenerated file (which is commited to my version control
flutter test
env:
FLUTTER_ROOT: /opt/hostedtoolcache/flutter/stable-3.16.6-x64
lib/ioc/dependency_injection.config.dart:54:51: Error: The argument type 'AppVersionLocalDataSource' can't be assigned to the parameter type 'AppVersionLocalDataSource Function()'.
- 'AppVersionLocalDataSource' is from 'package:eco_toss/data/app_version/app_version_local_data_source.dart' ('lib/data/app_version/app_version_local_data_source.dart').
gh.singleton<_i3.AppVersionLocalDataSource>(_i3.AppVersionLocalDataSource());
^
lib/ioc/dependency_injection.config.dart:57:47: Error: The argument type 'AppVersionRepository' can't be assigned to the parameter type 'IAppVersionRepository Function()'.
- 'AppVersionRepository' is from 'package:eco_toss/data/app_version/app_version_repository.dart' ('lib/data/app_version/app_version_repository.dart').
- 'IAppVersionRepository' is from 'package:eco_toss/data/app_version/i_app_version_repository.dart' ('lib/data/app_version/i_app_version_repository.dart').
gh.singleton<_i5.IAppVersionRepository>(_i6.AppVersionRepository(
My current fix
I've fixed my injectable version in pubspec.yaml:
# injectable: ^2.3.2 # before
injectable: "2.3.2" # after
and I am not experiencing any more issues with flutter test or flutter build in CI/CD.
The same problem
@juskek @mormih make sure you're using the latest versions of both injectable and injectable_generator, the issue above has been resolved.
i get the same error even upgrading both!
as you stated, i tried to upgrade both the injectable and injectable_generator, but another issue arised.
after upgrade:
injectable 2.4.0
injectable_generator 2.6.1
the new error was:
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());
^`
is there any solution to this?