Sitelet https://github.com/flutter/flutter/pull/191573
Skip to content

fix: stop flutter create --platforms from dropping existing platfor… - #191573

Merged
auto-submit[bot] merged 13 commits into
flutter:masterfrom
Shawn-Yu-Dev:fix-platforms-dropped-metadata
Sep 9, 2026
Merged

auto-submit[bot] merged 13 commits into
flutter:masterfrom
Shawn-Yu-Dev:fix-platforms-dropped-metadata

Conversation

@Shawn-Yu-Dev

@Shawn-Yu-Dev Shawn-Yu-Dev commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

…ms in .metadata

Fixes an issue where running flutter create --platforms=<new-platform> . overwrites the existing platform list in .metadata instead of appending to it.

Fixes #191567

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@google-cla

google-cla Bot commented Aug 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the flutter create command to seed the migration configuration with platforms already tracked in an existing .metadata file, preventing previously added platforms from being dropped when re-running the command. It also adds a test to verify this behavior. The review feedback suggests wrapping the .metadata parsing logic in a try-catch block to handle potentially corrupted or malformed files gracefully, preventing the tool from crashing.

Comment thread packages/flutter_tools/lib/src/commands/create_base.dart Outdated

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Just a couple of comments.

Comment thread .vscode/settings.json Outdated
Comment thread packages/flutter_tools/lib/src/commands/create_base.dart Outdated
@bkonyi bkonyi added the CICD Run CI/CD label Aug 24, 2026
@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I will batch these fixes together in the next commit.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 24, 2026
@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

It's ready for review! Please take a look when you have a chance, thanks!

@Shawn-Yu-Dev
Shawn-Yu-Dev requested a review from bkonyi August 25, 2026 03:30
// existing .metadata file. Re-running `flutter create --platforms` must
// add the newly requested platforms without dropping the previously
// added ones, and without overwriting their recorded revisions.
// See https://github.com/flutter/flutter/issues/191567.

@Gustl22 Gustl22 Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that comment is a bit confusing.
There is also this use case:

  • One adds a platform / multiple platforms, let's say: --platforms=android,ios
  • One recreates specific platform folders, to start from scratch (this was also common in packages repo to migrate to newer project standards, as not everything is migrated and/or additionally adds a new platform: --platforms=ios,linux

So I would recommend somethinng like:

      // ... Re-running `flutter create --platforms` must
      // add the platform without dropping or overwriting the previously
      // added ones, if they didn't exist yet.

Can we test the second case, too? So an entry for ios won't get duplicated (appended)?

@Shawn-Yu-Dev
Shawn-Yu-Dev force-pushed the fix-platforms-dropped-metadata branch 2 times, most recently from 7060e71 to fb40abe Compare August 26, 2026 01:35
@Shawn-Yu-Dev

Shawn-Yu-Dev commented Aug 26, 2026 via email •

Copy link
Copy Markdown
Contributor Author

@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

Hi @bkonyi,

Sorry for the ping! The PR has been waiting for the "Flutter Roll on Borg / Google testing" approval for over 12 hours now.

I've fully fixed my local environment issues and successfully ran the entire suite. The command dart test test/commands.shard/permeable/create_test.dart passed flawlessly on my Manjaro machine with 181 tests green (1 skipped due to platform restrictions).

This fully validates the idempotency fix—ensuring that running flutter create multiple times on the same platform introduces no duplicate entries in the metadata.

Since this fix was delegated by you, could you please take a quick moment to check Frob and click the "Run tests now" button to unblock the internal Borg CI queue?

Thank you so much for your time and guidance! 🚀

@Gustl22

Gustl22 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

@Shawn-Yu-Dev you should always check, what you have actually commited and verify your results, e.g. here in Github diff. There are now many files, which don't belong in a PR at all. See .reasonx and .vscode changes.

@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

Ah, I keep overlooking this. I’ve already discarded the changes to those files.

@bkonyi bkonyi added the CICD Run CI/CD label Aug 31, 2026
Comment thread packages/flutter_tools/lib/src/commands/create_base.dart Outdated
Comment thread packages/flutter_tools/test/commands.shard/permeable/create_test.dart Outdated
@Shawn-Yu-Dev

Shawn-Yu-Dev commented Sep 2, 2026 via email •

Copy link
Copy Markdown
Contributor Author

@Shawn-Yu-Dev
Shawn-Yu-Dev force-pushed the fix-platforms-dropped-metadata branch from 3b2bba7 to 511d4f6 Compare September 2, 2026 11:38
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 2, 2026
@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

@bkonyi Thanks for the review! I've updated the PR to address this feedback. Please take another look.

@bkonyi bkonyi added the CICD Run CI/CD label Sep 4, 2026
@bkonyi
bkonyi requested a review from chingjun September 4, 2026 15:21
bkonyi
bkonyi previously approved these changes Sep 4, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

chingjun
chingjun previously approved these changes Sep 4, 2026
@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit

auto-submit Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/191573, because - The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Shawn-Yu-Dev
Shawn-Yu-Dev force-pushed the fix-platforms-dropped-metadata branch from 0ec4485 to 4325291 Compare September 5, 2026 11:18
@bkonyi bkonyi added the CICD Run CI/CD label Sep 8, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit

auto-submit Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/191573, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Shawn-Yu-Dev

Copy link
Copy Markdown
Contributor Author

Thanks @bkonyi @chingjun for the approvals.

CI is green now (including Dashboard Checks, flutter-gold, and tree-status). The previous autosubmit label was removed because Dashboard Checks failed on an earlier run.

Could you please re-apply the autosubmit label when you have a moment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter create --platforms drops existing platforms from .metadata

4 participants