markclow / flutter_book_examples

189 stars 121 forks source link

Problem with key parameter in the stack_please_wait example. #3

Open theophany77 opened 1 month ago

theophany77 commented 1 month ago

Hi Marc !

I am Jean-michel from France. I bought your book "65 examples" recently and I am reading it carefully. It is very interesting and, I believe, straight to the point. I have a problem with the stack_please_wait code. I use Android Studio on Windows 10. When I paste the dart code in the main.dart, I have the following error 👍

class HomeWidget extends StatefulWidget {
  HomeWidget({Key key, this.title}) : super(key: key);

The parameter 'key' can't have a value of null because of its type but the implcit default value is null.

Same thing for the title parameter.

I don't know what to do. What is the type of the 'key' parameter ? When I try to initialize it, the type I use (int, String ...) is wrong.

Thanks for your help !

Jean-michel

theophany77 commented 1 month ago

After a few updates, it works ! That is what I did :

1) I added a "?" after each "Key" :

HomeWidget({Key? key, ........

2) I initialized the "title" parameter :

class HomeWidget extends StatefulWidget {
    var title;

Is it what you would have done, Marc ?

Regards.

Jean-michel.