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
- Use Flutter 3.44 / Dart 3.12 (stable channel, released 2026-05-15)
- Add
phosphor_flutter: ^2.1.0 to pubspec.yaml
- 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,
);
Description
Starting with Flutter 3.44 / Dart 3.12,
IconDatahas been declared as afinal 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
Steps to reproduce
phosphor_flutter: ^2.1.0topubspec.yamlflutter runorflutter buildEnvironment
Expected behavior
The package compiles successfully with the latest stable Flutter SDK.
Suggested fix
Remove the
PhosphorIconData extends IconDatasubclass and replace it with directIconDatainstances using the appropriatefontFamily,fontPackage,codePointandmatchTextDirectionparameters. This removes the dependency on subclassingIconDataentirely.Example: