Home > Software engineering >  Flutter Constructor
Flutter Constructor

Time:09-07

I am trying find out why my code includes this code const MyListView({Key? key}) : super(key: key); whilst all the youtube tutorials am following don't. For example my code runs like this

  const MyListView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

but the tutorial am following the code doesn't include

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

I am currently working with Builder and I don't know how to go about it

CodePudding user response:

The Key property is add newly to flutter, it is use to pass a key to your Custom widget in order to use it multiple time and can differ from each other. So it would not a big deal if you delete that line.

  • Related