How to declare multiple required variables on one line in Dart, Flutter?

257

It is currently not possible to summarize required parmeters. The Language Specification [1] requires that all are listed and fully written out.

Besides the Language Specification you can also have a look at the BNF of the language (e.g. this issue [2] provides some links to BNFs).

[1] https://dart.dev/guides/language/spec [2] https://github.com/dart-lang/sdk/issues/19298

Share:
257
Artur Jakucewicz
Author by

Artur Jakucewicz

Updated on December 31, 2022

Comments

  • Artur Jakucewicz
    Artur Jakucewicz about 1 year

    For shorter code, we can declare variables in one line. For example:

    late String day1, day2, day3, day4, day5, day6, day7;

    But how to declare required variables in the same way?

    required this.day1,
    required this.day2,
    required this.day3,
    required this.day4,
    required this.day5,
    required this.day6,
    required this.day7,
    
    • OMi Shah
      OMi Shah over 2 years
      but why do you need to specify required at a point where you haven't even declared your variables? What's the point?
  • Artur Jakucewicz
    Artur Jakucewicz over 2 years
    Thanks for answer. Ok let's wait for changes from Dart team.