dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.3k stars 1.59k forks source link

https://dart-lang.github.io/linter/lints/no_logic_in_create_state.html page lacks of advices #58647

Open Nashev opened 2 years ago

Nashev commented 2 years ago

Describe the issue When a newbie falls on linter check no_logic_in_create_state (#1875) and goes to that page, he can't realise how to write a workaround instead of bad code.

To Reproduce Write code like https://github.com/aliyigitbireroglu/flutter-image-sequence-animator/blob/877234de33f6a6dea42ff762e8610360927b92db/image_sequence_animator/lib/image_sequence_animator.dart#L122, obtain linter warning and go to the documentation on page https://dart-lang.github.io/linter/lints/no_logic_in_create_state.html

Try to find a workaround. Miss them...

Expected behaviour A clear and concise description of what you can do instead of using State's constructor arguments. Mentions of https://api.flutter.dev/flutter/widgets/State-class.html with links to initState and didChangeDependencies would be helpful there.

srawlins commented 2 years ago

I also can't read the very long sentence at https://dart-lang.github.io/linter/lints/no_logic_in_create_state.html.

And I agree, the GOOD example does not how/where to set field to 42.

stereotype441 commented 9 months ago

I'm going to take a stab at this.