Home > Software design >  Trying to use the super-parameters in old project after upgrading to flutter 3.0.0
Trying to use the super-parameters in old project after upgrading to flutter 3.0.0

Time:05-21

I am trying to use the new feature of dart (super-parameters) in my project, but every time the build is failed.

this is my code after the migration:

class ChildClass extends ParentClass {
  int? paramOne;
  String? paramTwo;

  ChildClass({
    this.paramOne,
    this.paramTwo,
    super.paramThree,
    super.paramFour,
  });
// ...

this is the error message:

[        ] dart_project/lib/src/model/app_model.dart:407:5: Error: The 'super-parameters' language feature is disabled for this library.
[    1 ms] Try removing the package language version or setting the language version to 2.17 or higher.
[        ]     super.paramThree,
[        ]     ^^^^^

pubsec.yaml:

environment:
  sdk: '>=2.17.0 <3.0.0'

CodePudding user response:

You can run flutter clean to clear the cache and then run flutter pub get which will get all the dependencies without cache.

  • Related