0

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?

Mr. Tacio
  • 442
  • 1
  • 7
  • 18

2 Answers2

1

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
Milan Surelia
  • 884
  • 1
  • 8
  • 18
  • Please let me know if my answer helped you out. If so, I would appreciate if you could accept my answer If you still have questions, feel free to ask – Milan Surelia Jan 18 '23 at 08:49
  • I think there must be some "reasonable grounds" of this warning. why should we go around ? but not solve ? – isa Jan 26 '23 at 10:40
1

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

Mr. Tacio
  • 442
  • 1
  • 7
  • 18