material-components / material-components-flutter-codelabs

Codelabs for Material Components for Flutter
212 stars 244 forks source link

MDC 101 Step 5 Add the buttons thows errors and prevents compiling #304

Closed geniuswebtools closed 1 month ago

geniuswebtools commented 1 month ago

Debug errors: lib/login.dart:66:30: Error: Not a constant expression. onPressed: () { ^^ lib/login.dart:74:30: Error: Not a constant expression. onPressed: () {

I have no idea how to resolve this, so based on the Codelab copy, I just replaced the callback functions with null. I was able to hotload the UI, and yes, both buttons were disabled, but now I feel like I can move forward with the codelab.

geniuswebtools commented 1 month ago

It would appear this is because I kept following the instructions from the blue squiggly lines saying "This needs to be a const!".... and that was the cause of this issue. I don't know. I can't find documentation on when const is needed vs when it's not, and all of the examples and videos I find, say, "don't worry about const, it only makes your app work better..." #frustrated.

geniuswebtools commented 1 month ago

Close.