1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How does a constructor accepts super.key in flutter?

Discussão em 'Mobile' iniciado por Stack, Outubro 17, 2024 às 05:22.

  1. Stack

    Stack Membro Participativo

    I am just starting out with Flutter, and Dart.

    I was looking at the code, how are the following block of code equal?

    const HomeScreen ({Key? key}) : super(key: key);


    const HomeScreen ({super.key});


    I got it, the ({super.key}) is passing the value to the parent constructor and executing the parent class but how? super(Key key) should have been the way to pass the key value not super.key in the children class constructor. And, another thing that {} is used for functions with named parameter function and we need to provide the name for which we need to pass value, but in the case for HomeScreen({super.key}) we're not even mentioning the name for which we are passing values?

    If anyone could explain or provide the links to study this matter.

    Continue reading...

Compartilhe esta Página