gpt4 book ai didi

android-studio - 如何抑制 'The declaration isn' t 引用的文件的 Dart 分析警告?

转载 作者:行者123 更新时间:2023-12-03 03:32:53 26 4
gpt4 key购买 nike

我的项目中有一个生成的 dart 文件,其中包含一些未使用的方法——这些未使用的方法导致 Android Studio 中的 Dart 分析服务器对每个未使用的方法发出警告。
警告如下所示:info: The declaration '<method name>' isn't referenced. (unused_element at [<app name>] lib/Models/<file name>.g.dart:<line number of method>)如何仅针对生成的文件抑制这些警告?

最佳答案

从步骤 5 here (整篇文章值得一读)

Warnings in generated files do not matter to you.Generated files are out of your control. You shouldn’t edit them, and probably shouldn’t care about how the generated code looks like either.As such, instead of polluting your IDE with tons of pointless warning, simply disabling the linter on generated files is enough. This can be done by adding some code to your analysis_options.yaml.In our case, we will use both json_serializable and Freezed, so the code what we want to add is:

analyzer:
exclude:
# ignore warnings in files from json_serializable, built_value and most generators
- "**/*.g.dart"
# ignore warnings in files generated by Freezed specifically.
- "**/*.freezed.dart"

关于android-studio - 如何抑制 'The declaration isn' t 引用的文件的 Dart 分析警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62886274/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com