Skip to content

[infra] Support snippets with omissions #3688

Open

Description

@liamappelbe

From #3641 (comment)

It would be cool if we could have snippets where we can omit things

// snippet-start#dangerous
Future<void> dangerousCall() async {
  // Do x-y-z.
  // snippet-omit-start
  // 1. Get the Activity (e.g., Activity "A")
  final activity = androidActivity(engineId);

  // 2. An `await` occurs. The main thread is freed.
  //    While waiting, Android might destroy Activity "A" and create "B".
  await someOtherFuture();

  // 3. CRASH: The code resumes, but `activity` is now a stale
  //    reference to the destroyed Activity "A".
  if (activity != null) {
    someGeneratedApi.doSomething(activity); // This will crash
    activity.release();
  }
  // snippet-omit-end
}
// snippet-end#dangerous

Which would then become

Future<void> dangerousCall() async {
  // Do x-y-z.
  // [...]
}

Activity

  1. vikramsingh920 commented on Sep 25, 2026

    @vikramsingh920
    Contributor

    hii @liamappelbe, I’d like to work on this issue.
    I’ve been looking through the snippet tooling changes from #3641, and I’m interested in implementing support for snippet-omit-start / snippet-omit-end.

    Would it be okay if I take this issue?

  2. liamappelbe commented on Sep 28, 2026

    @liamappelbe
    ContributorAuthor

    This is just some low priority internal infrastructure. I'm not sure we have a use case for it yet. Probably best to wait until we do.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-infraA repository infrastructure change or enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions