DealORound / Deal-O-Round

Flutter port of the Deal-O-Round board card game
MIT License
2 stars 0 forks source link

Refactor for `no_logic_in_create_state` code style rule #30

Closed MrCsabaToth closed 8 months ago

MrCsabaToth commented 8 months ago

This refactor can have consequences. Ref https://dart.dev/tools/linter-rules/no_logic_in_create_state Ref https://stackoverflow.com/questions/50818770/passing-data-to-a-stateful-widget-in-flutter

The problem is that in the State object's constructor I cannot yet access the widget final variables. This is why I passed them down in the custom constructor parameter. But now that is a no-no. So now I'll convert state variables to late and initialize them in initState. That might be a slippery slope because back in the past rarely I got run-time crashes because it wasn't satisfactory for the Flutter framework to init late variables in the initState, maybe initState was too lengthy and it took too long, so it was too late? Right now for Deal-O-Round it seems to work.