Skip to content

fix!: support Flutter 3.43+ IconData final-class change#62

Open
subarnaPdl wants to merge 1 commit into
phosphor-icons:mainfrom
subarnaPdl:main
Open

fix!: support Flutter 3.43+ IconData final-class change#62
subarnaPdl wants to merge 1 commit into
phosphor-icons:mainfrom
subarnaPdl:main

Conversation

@subarnaPdl

@subarnaPdl subarnaPdl commented May 19, 2026

Copy link
Copy Markdown

Fixes #61, Fixes #64.

Problem

Flutter 3.43 marks IconData as a final class (breaking change), which breaks the current inheritance hierarchy:

Error: The class 'IconData' can't be extended outside of its library because it's a final class.

This affects:

  • PhosphorIconData
  • PhosphorFlatIconData
  • PhosphorDuotoneIconData

The package currently fails to compile on Flutter 3.43+.

Approach

This PR migrates the package away from IconData inheritance while preserving the existing public usage patterns as much as possible.

API compatibility

  • PhosphorIconData is now a typedef to IconData.
  • PhosphorFlatIconData and PhosphorDuotoneIconData have been removed.
  • Generated icons are now plain IconData instances.
  • PhosphorIcon still extends Icon, so APIs such as find.byIcon, find.widgetWithIcon, and IconTheme integration continue to work unchanged.
  • Duotone rendering is preserved through a generated lookup:
PhosphorIconsDuotone.secondaryFor(primaryIcon)

PhosphorIcon uses this lookup internally to render the secondary glyph automatically for duotone icons.

Breaking changes

  • Removed PhosphorFlatIconData.
  • Removed PhosphorDuotoneIconData.
  • Removed PhosphorIconData(int codePoint, String style) constructor.
  • Duotone icons rendered directly with Flutter's Icon widget will display only the foreground glyph. PhosphorIcon continues 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.dart updated to emit the new forms. Regenerating reproduces the committed icon files.
  • bin/pubspec.yaml SDK constraint bumped to >=3.0.0 (the generator itself no longer runs on Dart 2.x because of upstream archive and http breaking changes).

Not included

  • Version bump. Left to maintainer discretion.
  • CHANGELOG.md updates. Existing changelog entries appear to be maintainer-managed.

Comm4nd0 added a commit to Comm4nd0/luma-support that referenced this pull request May 20, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant