Skip to content

Add a "design discussion" section to the setState method #12296

@konmik

Description

@konmik

I just started playing with Flutter, and the most obvious stuff is setState. Honestly, it does not look good. Why would you want to put all your mutations into a lambda, especially if they are all side-effecting? Wouldn't it be better just to call update() directly after you do all the state mutations?

The pattern looks like it came from a functional architecture, but the main point is missing - state mutation should have been encapsulated inside setState function, but this is not the case for Flutter. Without immutability, pure lambda and state change encapsulation all of this doesn't seems have any meaning.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions