Skip to content

Conversation

@elliette
Copy link
Member

Resolves #168846

This is a follow-up to #167677. For apps that do not import package:cupertino_icons, the new on-device button's icon shows up as a [?].

This fix:

  • adds an explicit dependency on package:cupertino_icons to the framework
  • imports CupertinoIcons into lib/src/widgets/app.dart

Note: For some reason, adding the import to packages/flutter/lib/src/material/app.dart and packages/flutter/lib/src/cupertino/app.dart did not resolve the issue. That's why I've added it to lib/src/widgets/app.dart, even though it's not actually used in that file.

Let me know if this is acceptable! (cc @Piinks) I'm guessing we might not want to add a dependency on cupertino_icons to the Framework (this might even be breaking change?) so if not, it might make sense to use a different icon for the on-device inspector. Thanks!

@elliette elliette requested review from Piinks and kenzieschmoll May 14, 2025 17:42
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label May 14, 2025
@elliette elliette changed the title Missing cupertino icon [Widget Inspector] Fix missing cupertino icon in on-device inspector May 14, 2025
@elliette elliette requested a review from LongCatIsLooong May 14, 2025 17:43
import 'dart:collection' show HashMap;

// ignore: unused_import, required for the Widget Inspector's on-device button.
import 'package:flutter/cupertino.dart' show CupertinoIcons;
Copy link
Contributor

Choose a reason for hiding this comment

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

Importing cupertino into the widgets library is layer violation and I don't think the analyzer script is going to like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Uhm I don't see the symbols imported from CupertinoIcons being used anywhere. Does it work without this import?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately no, that's why I added this note to the PR:

For some reason, adding the import to packages/flutter/lib/src/material/app.dart and packages/flutter/lib/src/cupertino/app.dart did not resolve the issue. That's why I've added it to lib/src/widgets/app.dart, even though it's not actually used in that file.

I first tried adding the import to where we are actually using the icon (in the two files mentioned above) however despite that change I was still seeing the [?] instead of the icon. I do not understand why though 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

@LongCatIsLooong is right, this is not something we can do.

Copy link
Contributor

Choose a reason for hiding this comment

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

You tested in debug mode (so no icon tree shaking) right? In that case I don't know off the top of my head. I'll try to debug this.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

  • adds an explicit dependency on package:cupertino_icons to the framework
  • imports CupertinoIcons into lib/src/widgets/app.dart

These are not things we can do. Is there another solution we can explore?

@elliette
Copy link
Member Author

These are not things we can do. Is there another solution we can explore?

The two other options I can think of are:

  1. Add a png asset to the framework that we could be used for the on-device button (my preference)
  2. Use a Material icon for the on-device button (unfortunately there aren't any good matches for the inspector)

Would option #1 be possible?

@Piinks
Copy link
Contributor

Piinks commented May 14, 2025

Add a png asset to the framework that we could be used for the on-device button

We need to avoid checking in binary assets in this repository.

Use a Material icon for the on-device button

If we need to import it into the widgets layer, we run into the same issue. The widgets layer and below cannot establish a dependency on a higher design level.

What about using unicode characters for a generic icon?
We did this in TreeSliver to manage these constraints:

child: const Icon(IconData(0x25BA), size: 14),

@github-actions github-actions bot added the f: cupertino flutter/packages/flutter/cupertino repository label May 14, 2025
@elliette
Copy link
Member Author

Importing cupertino_icons into lib/src/material/app.dart and lib/src/cupertino/app.dart actually does work (thank you@LongCatIsLooong for pointing that out! I'm guessing there was some user error on my part that made it seem it wasn't working) However, I'm guessing this still isn't possible due to the direct dependency on cupertino_icons in the framework's pubspec, is that correct @Piinks ?

If we need to import it into the widgets layer, we run into the same issue. The widgets layer and below cannot establish a dependency on a higher design level.

Fortunately, we wouldn't be importing this directly into the widgets layer, the Material and Cupertino styled on-device buttons are defined in packages/flutter/lib/src/material/app.dart and packages/flutter/lib/src/cupertino/app.dart, and then "imported" into the widgets layer via these button builders:

/// Builds the widget the [WidgetInspector] uses to exit selection mode.
///
/// This lets [MaterialApp] and [CupertinoApp] use an appropriately styled
/// button for their design systems without requiring [WidgetInspector] to
/// depend on the Material or Cupertino packages.
final ExitWidgetSelectionButtonBuilder? exitWidgetSelectionButtonBuilder;
/// Builds the widget the [WidgetInspector] uses to move the exit selection
/// mode button.
///
/// This lets [MaterialApp] and [CupertinoApp] use an appropriately styled
/// button for their design systems without requiring [WidgetInspector] to
/// depend on the Material or Cupertino packages.
final MoveExitWidgetSelectionButtonBuilder? moveExitWidgetSelectionButtonBuilder;
/// Builds the widget the [WidgetInspector] uses to change the default
/// behavior when tapping on widgets in the app.
///
/// This lets [MaterialApp] and [CupertinoApp] use an appropriately styled
/// button for their design systems without requiring [WidgetInspector] to
/// depend on the Material or Cupertino packages.
final TapBehaviorButtonBuilder? tapBehaviorButtonBuilder;

@Piinks
Copy link
Contributor

Piinks commented May 14, 2025

I am wary of adding cupertino_icons as a dependency to the framework. The framework needs to separate itself from design, not integrate more with it. I understand the cupertino icons are aesthetically pleasing, but I don't think that justifies adding them as a dependency for this one feature.

@github-actions github-actions bot added the f: material design flutter/packages/flutter/material repository. label May 14, 2025
@elliette
Copy link
Member Author

I am wary of adding cupertino_icons as a dependency to the framework. The framework needs to separate itself from design, not integrate more with it. I understand the cupertino icons are aesthetically pleasing, but I don't think that justifies adding them as a dependency for this one feature.

Got it! I've updated the PR to use a Material icon and remove the dependency of cupertino_icons. This does mean we are now importing the Material icons into lib/src/cupertino/app.dart, let me know if this is okay.

Here is what it looks like now:

Material-themed app
Screenshot 2025-05-14 at 4 00 34 PM

Cupertino-themed app
Screenshot 2025-05-14 at 4 01 45 PM

@elliette
Copy link
Member Author

Got it! I've updated the PR to use a Material icon and remove the dependency of cupertino_icons. This does mean we are now importing the Material icons into lib/src/cupertino/app.dart, let me know if this is okay.

Ah, I see from the tests this is not allowed! Marking PR is draft for now while I figure out what icons we want to use here.

@elliette elliette marked this pull request as draft May 15, 2025 16:55
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@elliette elliette marked this pull request as ready for review May 15, 2025 17:25
@elliette
Copy link
Member Author

Switched to a generic unicode symbol for both Material and Cupertino per @Piinks original suggestion 😅 Thanks for your patience with all the back-and-forth! This should be ready for review now.

Material app:
Screenshot 2025-05-15 at 10 22 55 AM

Cupertino app:
Screenshot 2025-05-15 at 10 05 40 AM

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Ah thank you! So glad unicode had some good options.
LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 19, 2025
@elliette elliette added the cp: beta cherry pick this pull request to beta release candidate branch label May 19, 2025
@flutteractionsbot
Copy link

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

elliette added a commit to elliette/flutter that referenced this pull request May 19, 2025
…lutter#168847)

Resolves flutter#168846

This is a follow-up to flutter#167677.
For apps that do not import `package:cupertino_icons`, the new on-device
button's icon shows up as a `[?]`.

This fix:
* adds an explicit dependency on `package:cupertino_icons` to the
framework
* imports `CupertinoIcons` into `lib/src/widgets/app.dart`

*Note: For some reason, adding the import to
`packages/flutter/lib/src/material/app.dart` and
`packages/flutter/lib/src/cupertino/app.dart` did not resolve the issue.
That's why I've added it to `lib/src/widgets/app.dart`, even though it's
not actually used in that file.*

**Let me know if this is acceptable!** (cc @Piinks) I'm guessing we
might not want to add a dependency on `cupertino_icons` to the Framework
(this might even be breaking change?) so if not, it might make sense to
use a different icon for the on-device inspector. Thanks!
elliette added a commit to elliette/flutter that referenced this pull request May 19, 2025
…lutter#168847)

Resolves flutter#168846

This is a follow-up to flutter#167677.
For apps that do not import `package:cupertino_icons`, the new on-device
button's icon shows up as a `[?]`.

This fix:
* adds an explicit dependency on `package:cupertino_icons` to the
framework
* imports `CupertinoIcons` into `lib/src/widgets/app.dart`

*Note: For some reason, adding the import to
`packages/flutter/lib/src/material/app.dart` and
`packages/flutter/lib/src/cupertino/app.dart` did not resolve the issue.
That's why I've added it to `lib/src/widgets/app.dart`, even though it's
not actually used in that file.*

**Let me know if this is acceptable!** (cc @Piinks) I'm guessing we
might not want to add a dependency on `cupertino_icons` to the Framework
(this might even be breaking change?) so if not, it might make sense to
use a different icon for the on-device inspector. Thanks!
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: beta cherry pick this pull request to beta release candidate branch f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Widget Inspector] New on-device button missing icon if Flutter app doesn't depend on cupertino_icons

5 participants