Skip to content

Conversation

@schultek
Copy link
Contributor

@schultek schultek commented Nov 20, 2025

Adds a component for downloading a code snippet as a file. This is displayed as a collapsed code block with additional action buttons in the title.

Provides three options:

  • Download directly using browser apis
  • Copy code to clipboard
  • Expand to show full code
Bildschirmfoto 2025-11-21 um 15 24 22

I also updated the CopyButton to extract its content from the actual code element instead of taking it as an parameter, to avoid duplicating the data in the output html.

@schultek schultek requested review from a team and sfshaza2 as code owners November 20, 2025 15:17
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @schultek, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience for interacting with code examples on the site by introducing a versatile SnippetDownloadButton component. This component provides users with convenient options to either download a code snippet as a file, copy its content to their clipboard, or view it in a new tab, directly from the documentation. The change involves both new UI components and a refactoring of how code snippets are presented.

Highlights

  • New Snippet Download Component: Introduced a SnippetDownloadButton component that allows users to download code snippets, copy them to the clipboard, or open them in a new browser tab.
  • Segmented Button UI: A new SegmentedButton widget and corresponding CSS styles were added to provide a cohesive UI for the download options.
  • Code Snippet Integration: The existing game-code.md tutorial snippet was refactored into a .dart file and integrated with the new SnippetDownloadButton component, demonstrating its usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 introduces a new SnippetDownloadButton component, which is a great enhancement for user experience, allowing users to download, copy, or open code snippets in a new tab. The implementation is well-structured, using a server-side component to fetch the snippet and a client-side component for the user interactions. I've identified a potential memory leak in the client-side component and a minor code clarity issue in the server-side component. My detailed feedback and suggestions for improvement are provided in the comments below.

@schultek schultek force-pushed the feat/download-code-button branch from c6c73d1 to 59cb69c Compare November 20, 2025 15:24
@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Nov 20, 2025

Visit the preview URL for this PR (updated for commit 1b1e2ec):

https://flutter-docs-prod--pr12733-feat-download-code-button-id2rvwh2.web.app

@schultek schultek requested a review from parlough November 20, 2025 15:25
@schultek schultek force-pushed the feat/download-code-button branch 4 times, most recently from 0fb2c19 to c202b44 Compare November 21, 2025 14:24
@schultek schultek force-pushed the feat/download-code-button branch from c202b44 to 1b1e2ec Compare November 21, 2025 14:44
@schultek
Copy link
Contributor Author

@parlough This is now updated to be a collapsed code block instead of just a button.

@schultek schultek changed the title Add SnippetDownloadButton component Add DownloadableSnippet component Nov 21, 2025
Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

This is perfect and works well across the browsers I tested. Thanks for making those adjustments @schultek!

@parlough parlough merged commit 2b2b79e into main Nov 23, 2025
9 checks passed
@parlough parlough deleted the feat/download-code-button branch November 23, 2025 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants