2

I am using the Flutter INTL package in my app for internationalization. The package generates a generated folder and I want the analyzer to ignore it.

I followed the Exclude code from analysis article however, it seems it doesn't work as two of the generated files won't be disappeared from the list.

image

This is my pubspec.yaml file.

name: luma_app
description: Luma My Account

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0

  # Firebase related libraries
  firebase_core: ^0.5.3         # https://pub.dev/packages/firebase_core
  firebase_crashlytics: ^0.2.4  # https://pub.dev/packages/firebase_crashlytics
  firebase_analytics: ^6.3.0    # https://pub.dev/packages/firebase_analytics
  firebase_auth: ^0.18.4+1      # https://pub.dev/packages/firebase_auth
  cloud_firestore: ^0.14.4      # https://pub.dev/packages/cloud_firestore
  firebase_storage: ^5.2.0      # https://pub.dev/packages/firebase_storage

  # Internationalization package helps us to manage different languages
  intl: ^0.16.1                 # https://pub.dev/packages/intl

  provider: ^4.3.2+3            # https://pub.dev/packages/provider
  google_fonts: ^1.1.1          # https://pub.dev/packages/google_fonts
  package_info: ^0.4.3+2        # https://pub.dev/packages/package_info/install
  shared_preferences: ^0.5.12+4 # https://pub.dev/packages/shared_preferences
  get_it: ^5.0.3                # https://pub.dev/packages/get_it
  flutter_svg: ^0.19.1          # https://pub.dev/packages/flutter_svg
  native_pdf_view: ^3.9.0       # https://pub.dev/packages/native_pdf_view

dev_dependencies:
  flutter_test:
    sdk: flutter
  pedantic: ^1.9.2              # https://pub.dev/packages/pedantic
#  effective_dart: ^1.3.0        # https://pub.dev/packages/effective_dart

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  generate: true # This is for localizations. Don't remove it.

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  assets:
    - assets/google_fonts/
    - assets/images/

flutter_intl:
  enabled: true

and finally, this is the content of my analysis_options.yaml file.

# For more information visit:
# https://dart.dev/guides/language/analysis-options

#include: package:pedantic/analysis_options.yaml
# or
include: package:pedantic/analysis_options.1.9.0.yaml
#include: package:effective_dart/analysis_options.1.3.0.yaml

analyzer:
  exclude:
    - lib/generated/**
#  strong-mode:
#    implicit-casts: false
#    implicit-dynamic: false
#  errors:
#    prefer_single_quotes: ignore

linter:
  rules:
    - camel_case_types

Dart/OS versions:

==> dart --version
Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "macos_x64"
Hesam
  • 52,260
  • 74
  • 224
  • 365
  • Have you restarted the analyzer since changing the file? – Randal Schwartz Jan 04 '21 at 16:41
  • @RandalSchwartz, I thought it is an automatic process. Isn't it? I am saying this because I had a long list of issues (including these two) and they disappeared after I fixed issues automatically. If it is manual or there is a way then how can I do that? – Hesam Jan 04 '21 at 16:48

1 Answers1

1

I realized that the documentation needs to be updated. You just need to remove lib/ from the path. So this configuration would work:

analyzer:
  exclude:
    - generated/**
Hesam
  • 52,260
  • 74
  • 224
  • 365