fix!: support Flutter 3.43+ IconData final-class change - #62
Conversation
phosphor_flutter 2.1.0 (the latest on pub.dev, May 2024) extends
Flutter's `IconData`, which 3.43+ sealed as `final`. Building against
Flutter 3.44 fails the kernel_snapshot Dart AOT step with:
phosphor_icon_data.dart:5:32: Error: The class 'IconData' can't be
extended outside of its library because it's a final class.
class PhosphorIconData extends IconData {
Upstream PR #62 turns PhosphorIconData into a typedef for IconData but
has been open with no maintainer response since May 2026, and the
package's last release is from May 2024 — effectively unmaintained.
Pin phosphor_flutter to the PR author's fork at a specific commit SHA
via dependency_overrides so the lockfile stays reproducible. None of
the removed classes (PhosphorFlatIconData, PhosphorDuotoneIconData)
are referenced by the app — only PhosphorIcon, PhosphorIconsDuotone,
and duotoneSecondaryColor, all of which the fork keeps API-compatible.
Drop the override when upstream publishes a fixed version (or when we
migrate to a maintained icon library).
phosphor-icons/flutter#61
phosphor-icons/flutter#62
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@rektdeckard any idea when we can get this merged and released on pub.dev? phosphor-icons is the only package that is blocking me to release to fix my own package for the latest Flutter version All these packages are currently broken: |
|
We hit this exact break in production (IconData final-class error building against Flutter 3.44) and are currently running an app off this branch via a dependency_overrides git pin. It resolves the compile error cleanly for us, would be great to see this merged, since pub.dev's 2.1.0 is now broken against any current Flutter SDK. |
|
Im already using this repo, and its working perfectly fine, cause its taking so long to merge this PR |
Fixes #61, Fixes #64.
Problem
Flutter 3.43 marks
IconDataas afinalclass (breaking change), which breaks the current inheritance hierarchy:This affects:
PhosphorIconDataPhosphorFlatIconDataPhosphorDuotoneIconDataThe package currently fails to compile on Flutter 3.43+.
Approach
This PR migrates the package away from
IconDatainheritance while preserving the existing public usage patterns as much as possible.API compatibility
PhosphorIconDatais now a typedef toIconData.PhosphorFlatIconDataandPhosphorDuotoneIconDatahave been removed.IconDatainstances.PhosphorIconstill extendsIcon, so APIs such asfind.byIcon,find.widgetWithIcon, andIconThemeintegration continue to work unchanged.PhosphorIconuses this lookup internally to render the secondary glyph automatically for duotone icons.Breaking changes
PhosphorFlatIconData.PhosphorDuotoneIconData.PhosphorIconData(int codePoint, String style)constructor.Iconwidget will display only the foreground glyph.PhosphorIconcontinues to render both layers automatically.The following continue to work unchanged:
Icon(PhosphorIcons.x())Icon(PhosphorIconsRegular.x)PhosphorIcon(...)find.byIcon(...)find.widgetWithIcon(...)List<IconData>Generator
bin/generate_package_icons.dartupdated to emit the new forms. Regenerating reproduces the committed icon files.bin/pubspec.yamlSDK constraint bumped to>=3.0.0(the generator itself no longer runs on Dart 2.x because of upstreamarchiveandhttpbreaking changes).Not included
CHANGELOG.mdupdates. Existing changelog entries appear to be maintainer-managed.