invalid_
                  The member '{0}' can only be used for overriding.
Description
#
                    The analyzer produces this diagnostic when an instance member that is
                    annotated with visibleForOverriding
                     is
                    referenced outside the library in which it's declared for any reason other
                    than to override it.
                  
Example
#Given a file a.dart containing the following declaration:
import 'package:meta/meta.dart';
class A {
  @visibleForOverriding
  void a() {}
}
                    The following code produces this diagnostic because the method m is being
                    invoked even though the only reason it's public is to allow it to be
                    overridden:
                  
import 'a.dart';
class B extends A {
  void b() {
    a();
  }
}
Common fixes
#Remove the invalid use of the member.
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.