const, final, dynamic, var... when and why? | Dart & Flutter tutorial

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

Комментарии • 2

  • @piffyization
    @piffyization 2 года назад +1

    Thanks for your video. I have a quick question. Const is compile time, does that mean better performance? (even if minimal). Or do you recommend using final for constants.

    • @DavidSerranoIO
      @DavidSerranoIO  2 года назад +2

      I think that yes, it means better performance in the end. You should always use const when possible, also, take a look at the following lint rules:
      - dart-lang.github.io/linter/lints/prefer_const_declarations.html
      - dart-lang.github.io/linter/lints/prefer_const_constructors.html