Parameter can't have a value of null in flutter

You can also use positional parameters (no curly brackets) that are mandatory by default, so not nullable.


  void calculate(int factor) {
     // ...
  }


and is called without naming the parameter:

calculate(12);

These kind of parameters can be used on constructors this way:

class Foo extends StatelessWidget {
  final String myVar;

  const Foo(this.myVar, {Key? key}): super(key: key);

  // ...
}

and "can be followed either by named parameters OR by optional positional parameters (but not both)", see doc here: dart parameters

Comments

Popular posts from this blog

Moodle Backup and Restore in Docker

Custom Domain to GitHub Pages (Hostinger Edition)

Resizing partition in AWS