This pull request reverts the changes in #155757. The auto-formatter created conflicts in the master branch, so the revert was performed manually in #160643. For this cherry-pick PR, I was able to run `git revert 21381d843f3feb32640ae385aedd8e5c4003696b` without any problems. <br> ### Issue Links bug reports: #160196, #160555 cherry-pick request: #161176 ### Target stable ### Changelog Description Passing a list literal to a `DropdownMenu` causes the widget to reset to the `initialSelection` after each build. ### Impacted Users This affects anyone using the [DropdownMenu](https://api.flutter.dev/flutter/material/DropdownMenu-class.html) widget. ### Impact Description The impact usually consists of the text value being inconveniently reset each time the widget is rebuilt. (In some cases it can be a fatal crash: the code sample from #160196 shows how this change can lead to an infinite build loop.) ### Workaround This regression can be mitigated by caching & modifying a single list instance, rather than using a list literal for the `DropdownMenu` constructor. ### Risk low ### Test Coverage yes ### Validation Steps #160643 added a regression test for this revert. The fix can also be verified by running the code sample from #160196 and verifying that there is no infinite build loop.
Flutter Examples
This directory contains several examples of using Flutter. To run an example,
use flutter run inside that example's directory. See the getting started
guide to install the flutter tool.
For additional samples, see the
flutter/samples repo.
Available examples include:
-
Hello, world The hello world app is a minimal Flutter app that shows the text "Hello, world!"
-
Flutter gallery The flutter gallery app no longer lives in this repo. Please see the gallery repo.
-
Layers The layers vignettes show how to use the various layers in the Flutter framework. For details, see the layers README.
-
Platform Channel The platform channel app demonstrates how to connect a Flutter app to platform-specific APIs. For documentation, see https://flutter.dev/to/platform-channels/.
-
Platform Channel Swift The platform channel swift app is the same as platform channel but the iOS version is in Swift and there is no Android version.
Notes
Note on Gradle wrapper files in .gitignore:
Gradle wrapper files should normally be checked into source control. The example projects don't do that to avoid having several copies of the wrapper binary in the Flutter repo. Instead, the Gradle wrapper is injected by Flutter tooling, and the wrapper files are .gitignore'd to avoid making the Flutter repository dirty as a side effect of running the examples.