3

I did a mistake by migrating to null-safety then every thing become error, after fixing a lot of errors, I still get an error and the error is :

[INFO] Generating build script...
[INFO] Generating build script completed, took 452ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 131ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 791ms

[INFO] Running build...
[INFO] Running build completed, took 30ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 79ms

[SEVERE] json_serializable:json_serializable on lib/injection.config.dart (cached):

This builder requires Dart inputs without syntax errors.
However, package:invoice_app/injection.config.dart (or an existing part) contains the following errors.
injection.config.dart:18:48: This requires the 'non-nullable' language feature to be enabled.
injection.config.dart:18:12: This requires the 'non-nullable' language feature to be enabled.

Try fixing the errors and re-running the build.

[SEVERE] Failed after 123ms
pub finished with exit code 1
ahmed
  • 444
  • 2
  • 9

1 Answers1

1

it's look like injectable generator have some mix up with the new version of dart that is why when I generate new injection.config.dart file then it gave this error

injection.config.dart:18:12: This requires the 'non-nullable' language feature to be enabled.

so if you want to fix it just open the file then then remove the ? mark like from this

_i1.GetIt $initGetIt(_i1.GetIt get,
    {String? environment, _i2.EnvironmentFilter? environmentFilter}) {
  final gh = _i2.GetItHelper(get, environment, environmentFilter);
  return get;
}

to this

_i1.GetIt $initGetIt(_i1.GetIt get,
    {String environment, _i2.EnvironmentFilter environmentFilter}) {
  final gh = _i2.GetItHelper(get, environment, environmentFilter);
  return get;
}

I know it's not a solution but it works until when I will migrate to non-nullable, I will use this.

ahmed
  • 444
  • 2
  • 9