Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Widget Previews] Widget inspector hides widgets from user's local project in implementation widgets #8807

Open
elliette opened this issue Jan 24, 2025 · 1 comment · May be fixed by #8808
Labels
P2 important to work on, but not at the top of the work list. screen: inspector

Comments

@elliette
Copy link
Member

Steps to repro:

  1. git clone https://github.com/bkonyi/widget_preview_study
  2. cd widget_preview_study/widget_preview
  3. flutter pub get
  4. cd ../veggieseasons
  5. flutter pub get
  6. open widget_preview_study/veggieseasons in your IDE
  7. add code below to veggie_card.dart
  8. run dart run ../widget_preview/bin/find_previews.dart in IDE terminal
  9. look for VM service URI and copy it
  10. launch devtools from IDE, then paste in VM service URI
  11. open the inspector

Expected: Widgets defined in veggie_card.dart should be considered part of the local project, and shown in the inspector tree when the implementation widgets are hidden
Actual: Widgets defined in veggie_card.dart are considered implementation widgets, and hidden in the inspector tree

Note: This is because we detect the pub root directory to be the preview scaffold, therefore anything outside of the preview scaffold is ignored:

Image

@bkonyi for widget previews, will the preview scaffold always match the path /flutter/app/directory/.dart_tool/preview_scaffold? If so, we could check if the pub root ends with .dart_tool/preview_scaffold and instead set it to be the parent directory of .dart_tool.

import 'package:veggieseasons/data/local_veggie_provider.dart';
import 'package:widget_preview/widget_preview.dart';

@Preview()
List<WidgetPreview> veggieCardPreview() {
  return [
    WidgetPreview(
      name: 'Veggie Card',
      child: VeggieCard(LocalVeggieProvider.veggies.first, false, true),
    ),
  ];
}
@elliette
Copy link
Member Author

From @bkonyi: "The generated project's name isn't stable yet, but I'm using widget_preview_scaffold for now and it'll live under .dart_tool/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 important to work on, but not at the top of the work list. screen: inspector
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant