flutter - How to disable invalid_annotation_target warning? - Stack Overflow

admin2025-04-19  0

Context

I released a package to pub.dev. The model classes were built with freezed. After release, I noticed that pana (the pub.dev's analysis tool) complaining about the following warnings and the package score significantly dropped.

Question

How do I make pana ignore these warnings?

What have I already done?

  • Gone through freezed package documentation and updated analysis_options.yaml (attached below)
  • Searched around found the following issues:
  • Ran dart analyze - no issues found!

analysis_options.yaml

include: package:lints/recommended.yaml

linter:
  rules:
    - camel_case_types: true
    - comment_references: true
    - dangling_library_doc_comments: true
    - public_member_api_docs: true
    - slash_for_doc_comments: true
    - unnecessary_library_directive: true

analyzer:
  exclude:
    - "**/*.g.dart"
    - "**/*.freezed.dart"
  errors:
    invalid_annotation_target: ignore

Here's the one of the 1000+ files pana is complaining about:

affiliate_info.dart

import 'package:freezed_annotation/freezed_annotation.dart';
import 'user.dart';
import 'chat.dart';

part 'affiliate_info.freezed.dart';
part 'affiliate_info.g.dart';

/// Contains information about the affiliate that received a commission via this
/// transaction.
@freezed
class AffiliateInfo with _$AffiliateInfo {
  /// Constructs an [AffiliateInfo] object.
  const factory AffiliateInfo({
    /// The bot or the user that received an affiliate commission if it was
    /// received by a bot or a user.
    @JsonKey(name: 'affiliate_user') User? affiliateUser,

    /// The chat that received an affiliate commission if it was received by a
    /// chat.
    @JsonKey(name: 'affiliate_chat') Chat? affiliateChat,

    /// The number of Telegram Stars received by the affiliate for each 1000
    /// Telegram Stars received by the bot from referred users.
    @JsonKey(name: 'commission_per_mille') required int commissionPerMille,

    /// Integer amount of Telegram Stars received by the affiliate from the
    /// transaction, rounded to 0; can be negative for refunds.
    @JsonKey(name: 'amount') required int amount,

    /// The number of 1/1000000000 shares of Telegram Stars received by the
    /// affiliate; from -999999999 to 999999999; can be negative for refunds.
    @JsonKey(name: 'nanostar_amount') int? nanostarAmount,
  }) = _AffiliateInfo;

  /// Creates an [AffiliateInfo] object from JSON.
  factory AffiliateInfo.fromJson(Map<String, dynamic> json) =>
      _$AffiliateInfoFromJson(json);
}

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745057471a282488.html

最新回复(0)