[Widget Inspector] Fix missing cupertino icon in on-device inspector (#168847)

Resolves https://github.com/flutter/flutter/issues/168846

This is a follow-up to https://github.com/flutter/flutter/pull/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!
This commit is contained in:
Elliott Brooks 2025-05-15 12:55:21 -07:00 committed by GitHub
parent cdd6be4798
commit 1329c8c2bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -568,9 +568,9 @@ class _CupertinoAppState extends State<CupertinoApp> {
return _CupertinoInspectorButton.toggle(
onPressed: onPressed,
semanticsLabel: semanticsLabel,
// This icon is also used for the Material-styled button and for DevTools.
// It should be updated in all 3 places if changed.
icon: CupertinoIcons.cursor_rays,
// This unicode icon is also used for the Material-styled button and for
// DevTools. It should be updated in all 3 places if changed.
icon: const IconData(0x1F74A),
toggledOn: selectionOnTapEnabled,
);
}

View File

@ -970,9 +970,9 @@ class _MaterialAppState extends State<MaterialApp> {
return _MaterialInspectorButton.toggle(
onPressed: onPressed,
semanticsLabel: semanticsLabel,
// This icon is also used for the Cupertino-styled button and for DevTools.
// It should be updated in all 3 places if changed.
icon: CupertinoIcons.cursor_rays,
// This unicode icon is also used for the Cupertino-styled button and for
// DevTools. It should be updated in all 3 places if changed.
icon: const IconData(0x1F74A),
isDarkTheme: _isDarkTheme(context),
toggledOn: selectionOnTapEnabled,
);