[flutter_tools] Fix crash when migrating flow-style exclude lists in analysis_options.yaml (#191269)
## Description Avoids a crash in the `yaml_edit` package when migrating `analysis_options.yaml` where the `exclude` list is formatted in flow style (e.g. `[ ... ]`) and contains internal newlines and trailing commas. The `yaml_edit` package (version 2.2.4) has a bug when appending to such lists via `appendToList`, which results in invalid YAML generation and triggers a `_YamlAssertionError` (tracked upstream in https://github.com/dart-lang/tools/issues/2532). To work around this, `AnalysisOptionsMigration` checks if the `exclude` list's style is `CollectionStyle.FLOW`. If it is, it updates the entire list using `editor.update` instead of appending. This converts the list to block style (which is preferred in `analysis_options.yaml`) and avoids the crash. Invalid types within the list are preserved for consistency with block-style migration. ## Related Issues Fixes https://github.com/flutter/flutter/issues/191060 Upstream issue: https://github.com/dart-lang/tools/issues/2532 ## Tests - Added `migrates and merges excludes when list is in flow style with newlines` to `packages/flutter_tools/test/general.shard/migrations/analysis_options_migration_test.dart`.
B
Ben Konyi committed
9479bb7773d49ab1904fd4c751e5314f3720bdea
Parent: 7c25794
Committed by GitHub <noreply@github.com>
on 8/21/2026, 7:56:37 PM