The parameter 'key' can't have a value of 'null' and The parameter 'title' can't have a value of 'null'

The parameter 'key' can't have a value of 'null' and The parameter 'title' can't have a value of 'null'


I have got two errors

1.  Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.


and 

2. Error: The parameter 'title' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.


This was my part of code


class MyHomePage extends StatelessWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
  final String title;


I have changed this code to 


class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, this.title=''}) : super(key: key);
  final String title;


and now it works.

Comments