invalid_export_of_internal_element_indirectly
The member '{0}' can't be exported as a part of a package's public API, but is indirectly exported as part of the signature of '{1}'.
Description
#The analyzer produces this diagnostic when a public library exports a top-level function with a return type or at least one parameter type that is marked with the internal
annotation.
Example
#Given a file a.dart
in the src
directory that contains the following:
import 'package:meta/meta.dart';
@internal
typedef IntFunction = int Function();
int f(IntFunction g) => g();
The following code produces this diagnostic because the function f
has a parameter of type IntFunction
, and IntFunction
is only intended to be used internally:
export 'src/a.dart' show f;
Common fixes
#If the function must be public, then make all the types in the function's signature public types.
If the function doesn't need to be exported, then stop exporting it, either by removing it from the show
clause, adding it to the hide
clause, or by removing the export.
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.