skip to Main Content

I’m having a warning message on _WordMarker
Avoid using private types in public APIs.

class WordMarker extends SingleChildRenderObjectWidget {
  final int index;

  const WordMarker({required Widget child, required this.index, Key? key})
      : super(child: child, key: key);

  @override
  RenderObject createRenderObject(BuildContext context) {
    return _WordMarker()..index = index;
  }

  //Warning message on _WordMarker
  @override
  void updateRenderObject(BuildContext context, _WordMarker renderObject) {
    renderObject.index = index;
  }
}

class _WordMarker extends RenderProxyBox {
  late int index;
}

I tried following these but I’m still unable to remove the warning message.
"Avoid using private types in public APIs" Warning in Flutter
"AVOID using library private types in public APIs" – lint warning, even in in cookbook examples?

2

Answers


  1. Chosen as BEST ANSWER

    I remove the "_" from _WordMarker and change it to MyWordMarker and the warning disappears.


  2. You can add this lint rule in analysis_options.yaml File & set the value to false to avoid these warnings.

    library_private_types_in_public_api: false
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search