💬

Invalid use of a private type in a public API.Try making the private の

2024/02/27に公開

Invalid use of a private type in a public API.
Try making the private type public, or making the API that uses the private type also be private.

というエラーが出る。

class SettingsPage extends StatefulWidget {
  const SettingsPage({super.key});

  @override
  /// この _SettingsPageStateの部分で、エラーが発生。
  _SettingsPageState createState() => _SettingsPageState();
}
 _SettingsPageState

State<SettingsPage>

に変更。
エラー解消。

Stateの位置を前に持ってきて、<>で囲む。

参考:https://stackoverflow.com/questions/72677634/avoid-using-private-types-in-public-apis-warning-in-flutter

Discussion