Is there a difference if I use excess "const" keywords?

0

Building flutter apps is all about code efficiency. Of course, when building a reactive application I would use "const" before widgets and classes with constant constructors. However, I would like to know if there is any PERFORMANCE and APP SIZE difference between the following examples:

const List<Color> colors = <Color>[
  Color(0xFFFFFFFF),
  Color(0xFF000000),
];

and

const List<Color> colors = <Color>[
  const Color(0xFFFFFFFF),
  const Color(0xFF000000),
];
flutter
dart
asked on Stack Overflow Aug 19, 2019 by Alexey Subbotin

1 Answer

2

No.

Since Dart 2.0, these redundant const keywords are optional.

So:

const foo = <T>[ Foo() ];

is strictly equivalent to:

const foo = const <T>[ const Foo() ];
answered on Stack Overflow Aug 19, 2019 by RĂ©mi Rousselet

User contributions licensed under CC BY-SA 3.0