Skip to content

Support Flutter 3.44+ (IconData is now a final class) - #66

Open
hiake21c wants to merge 1 commit into
phosphor-icons:mainfrom
hiake21c:flutter-3.44-support
Open

Support Flutter 3.44+ (IconData is now a final class)#66
hiake21c wants to merge 1 commit into
phosphor-icons:mainfrom
hiake21c:flutter-3.44-support

Conversation

@hiake21c

@hiake21c hiake21c commented Jul 26, 2026

Copy link
Copy Markdown

Problem

Flutter 3.44 marked IconData a final class (flutter/flutter#181342). The package's core type does:

class PhosphorIconData extends IconData { ... }

Extending a final class is now a compile error, so every build on Flutter 3.44+ fails:

lib/src/phosphor_icon_data.dart:5:32: Error: The class 'IconData' can't be
extended outside of its library because it's a final class.

Fix

Icons become plain IconData instances instead of an IconData subclass. The generated style classes now emit IconData(...) directly with the identical codePoint / fontFamily / fontPackage, so flat icons render unchanged. PhosphorIconData, PhosphorFlatIconData and PhosphorDuotoneIconData are kept as type aliases for backward compatibility. SDK floor bumped to Dart 3.0 (non-function typedefs) / Flutter 3.44.

Tradeoff (needs a maintainer decision)

Because a plain IconData cannot carry a second layer, duotone icons collapse to their foreground layer (single-tone) in this PR. Preserving true two-tone rendering is possible but requires a breaking PhosphorIcon redesign (duotone can no longer be an IconData, so Icon(duotoneConst) and the PhosphorIcon extends Icon relationship both change). I kept this PR minimal to unblock 3.44 builds — happy to extend it to a duotone-preserving design if you prefer that direction.

Notes

  • Constants were rewritten mechanically (the two generator output patterns), not hand-edited.
  • Verified: a full app on Flutter 3.44.8 analyzes clean and builds against this branch.

Flutter 3.44 marked `IconData` a `final class`
(flutter/flutter#181342), which makes
`class PhosphorIconData extends IconData` illegal and breaks every build
on Flutter 3.44+.

Icons are now plain `IconData` instances: the generated style classes emit
`IconData(...)` directly (identical codePoint/fontFamily/fontPackage, so
flat icons render unchanged), and `PhosphorIconData` / `PhosphorFlatIconData`
/ `PhosphorDuotoneIconData` are kept as type aliases for backward
compatibility. Bumps the SDK floor to Dart 3.0 (non-function typedefs) and
Flutter 3.44.

Tradeoff: duotone icons collapse to their foreground layer (single-tone),
since a plain `IconData` cannot carry the second layer. A two-tone-preserving
approach is possible but requires a breaking `PhosphorIcon` widget redesign;
this change prioritizes unblocking Flutter 3.44 builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant