Skip to content

Add flutter API linked snippets#846

Open
Pante wants to merge 2 commits intomainfrom
experiment/flutter-api-linked-snippets
Open

Add flutter API linked snippets#846
Pante wants to merge 2 commits intomainfrom
experiment/flutter-api-linked-snippets

Conversation

@Pante
Copy link
Copy Markdown
Member

@Pante Pante commented Feb 14, 2026

Describe the changes

Checklist

  • I have read the CONTRIBUTING.md.
  • I have included the relevant unit/golden tests.
  • I have included the relevant samples.
  • I have updated the documentation accordingly.
  • I have added the required flutters_hook for widget controllers.
  • I have updated the CHANGELOG.md if necessary.

Copilot AI review requested due to automatic review settings February 14, 2026 06:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for generating API documentation links to Flutter framework types in the documentation snippet generator. The changes enable the snippet generator to create proper links to api.flutter.dev for Flutter and dart:ui types, rather than treating them like regular pub.dev packages.

Changes:

  • Added Flutter package to the tracked packages list with special handling
  • Modified documentation URL generation to use api.flutter.dev for Flutter and dart:ui types
  • Updated tooltip generation to exclude Flutter types (since Flutter has its own comprehensive documentation)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs_snippets/tool/snippet_generator/main.dart Adds the Flutter package (using material.dart as the library entry point) to the list of tracked packages with an empty version string
docs_snippets/tool/snippet_generator/dart_doc_linker.dart Adds special URL generation for dart:ui types and Flutter package types to link to api.flutter.dev instead of pub.dev, and refactors the base URL construction logic
docs_snippets/tool/snippet_generator/tooltip_linker.dart Modifies the _forui method to explicitly exclude Flutter types from tooltip generation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +252 to +253
if (package == 'flutter') {
base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(barrel.uri.pathSegments.last)}';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Accessing barrel.uri.pathSegments.last could throw a StateError if the path segments list is empty. Consider adding a check to ensure the list is not empty before accessing .last, or handle the potential exception. For example, you could check if barrel.uri.pathSegments.isNotEmpty before accessing .last.

Suggested change
if (package == 'flutter') {
base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(barrel.uri.pathSegments.last)}';
final segments = barrel.uri.pathSegments;
if (package == 'flutter') {
if (segments.isEmpty) {
// Avoid StateError from accessing segments.last on an empty list.
continue;
}
base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(segments.last)}';

Copilot uses AI. Check for mistakes.
@auto-maid
Copy link
Copy Markdown
Contributor

auto-maid bot commented Feb 14, 2026

Documentation Preview

Latest Commit SHA 2904fd1
Preview URL https://11e7e48e-forui-docs-dev.duobase.workers.dev/docs

You're seeing this because the docs/samples were updated.

@Pante Pante force-pushed the main branch 3 times, most recently from 1c9628a to 4645318 Compare March 21, 2026 14:25
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