extension_ type_ representation_ depends_ on_ itself
The extension type representation can't depend on itself.
Description
#The analyzer produces this diagnostic when an extension type has a representation type that depends on the extension type itself, either directly or indirectly.
Example
#
The following code produces this diagnostic because the representation
type of the extension type
A
depends on
A
directly:
extension type A(A a) {}
The following two code examples produce this diagnostic because the
representation type of the extension type
A
depends on
A
indirectly through the extension type
B
:
extension type A(B b) {}
extension type B(A a) {}
extension type A(List<B> b) {}
extension type B(List<A> a) {}
Common fixes
#Remove the dependency by choosing a different representation type for at least one of the types in the cycle:
extension type A(String s) {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.