Skip to main content

prefer-correct-static-icon-provider

effort: 4m
pro+

Warns when a class with the @staticIconProvider annotation does not have IconData fields or any of those fields are not static.

All IconData fields must be static in order for tree shacking to work properly.

Example

❌ Bad:


abstract final class Some {
// LINT: IconData fields must be static const for the @staticIconProvider to have any effect.
// Try removing the annotation or making this field static const.
final IconData icon = IconData(1);
}

// LINT: This class has no IconData fields which makes @staticIconProvider redundant.
// Try removing the annotation or adding IconData fields.

abstract final class Some {}

✅ Good:


abstract final class Some {
static const IconData icon = IconData(1);
}

Additional Resources