0

Take this code for example:

class MyApp extends StatelessWidget {

 MyApp({Key? key}) : super(key: key);

 @override
 Widget build(BuildContext context) {
   //returns widget
 }
}

What I know
MyApp is constructor for the class which has field key. Initializer list consists of super(key: key).

So does it mean that I am assigning the key of MyApp to the key of its super constructor?

Is the super constructor StatelessWidget?

Why do we need to assign key to the super?

What happens if I don't do this initializing?

I am new to flutter and am trying to understand how things work, and why. Please help!

Ishaan
  • 43
  • 5

1 Answers1

1

I think you should take a look at this post, it explain more than it is needed.

what is Key parameter in the constructor

Yozmo
  • 521
  • 2
  • 10