Home > database >  what's the difference between using super.key and (Key? key) : super(key: key) in flutter
what's the difference between using super.key and (Key? key) : super(key: key) in flutter

Time:09-19

I want to know what's the main difference between using super.key and (Key? key) : super(key: key) in a flutter app, I mean I know they both set key from the super widgets, but why there is 2 types of them, and which is preferred to use.

CodePudding user response:

super.key is the new syntax, made available in Dart 2.17, which first came with Flutter 3.0. Details are at the release notes: https://dart.dev/guides/whats-new#may-11-2022-217-release

The new syntax is much shorter and cleaner, but you'll need to understand both forms for years to come.

  • Related