Skip to content

PhosphorIconData extends IconData breaks with Flutter 3.44 / Dart 3.12 (IconData is now final) #64

Description

@stefanBid

Description

Starting with Flutter 3.44 / Dart 3.12, IconData has been declared as a final class, making it impossible to subclass it outside of the Flutter library.

This causes a build failure when using phosphor_flutter 2.1.0.

Error

.pub-cache/hosted/pub.dev/phosphor_flutter-2.1.0/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.
class PhosphorIconData extends IconData {
                               ^

Steps to reproduce

  1. Use Flutter 3.44 / Dart 3.12 (stable channel, released 2026-05-15)
  2. Add phosphor_flutter: ^2.1.0 to pubspec.yaml
  3. Run flutter run or flutter build

Environment

  • Flutter 3.44.0 — stable channel
  • Dart 3.12.0
  • phosphor_flutter 2.1.0

Expected behavior

The package compiles successfully with the latest stable Flutter SDK.

Suggested fix

Remove the PhosphorIconData extends IconData subclass and replace it with direct IconData instances using the appropriate fontFamily, fontPackage, codePoint and matchTextDirection parameters. This removes the dependency on subclassing IconData entirely.

Example:

// Before
class PhosphorIconData extends IconData {
  const PhosphorIconData(int codePoint, String style)
      : super(
          codePoint,
          fontFamily: 'Phosphor$style',
          fontPackage: 'phosphor_flutter',
          matchTextDirection: true,
        );
}

// After
IconData phosphorIcon(int codePoint, String style) => IconData(
  codePoint,
  fontFamily: 'Phosphor$style',
  fontPackage: 'phosphor_flutter',
  matchTextDirection: true,
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions