Flutter Analyzer Setup for Code Quality Checking

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Flutter Analyzer Setup for Code Quality Checking
Simple
~1 business day
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Setting Up Flutter Analyzer for Code Quality

Flutter Analyzer is a built-in static analyzer for Dart/Flutter based on dart analyze. Without configuration it already works in IDE, but in CI it's often ignored or run without proper flags. Result: code with dynamic instead of typed variables, unused imports, deprecated API — all accumulates and migrates to production.

analysis_options.yaml

All analyzer settings are in analysis_options.yaml in project root:

include: package:flutter_lints/flutter.yaml

analyzer:
  exclude:
    - "**/*.g.dart"
    - "**/*.freezed.dart"
    - "lib/generated/**"
  errors:
    invalid_annotation_target: ignore  # for freezed
  language:
    strict-casts: true
    strict-inference: true
    strict-raw-types: true

linter:
  rules:
    # Include in addition to flutter_lints
    - always_use_package_imports
    - avoid_dynamic_calls
    - avoid_empty_else
    - avoid_print
    - avoid_relative_lib_imports
    - avoid_slow_async_io
    - avoid_type_to_string
    - cancel_subscriptions
    - close_sinks
    - comment_references
    - invariant_booleans
    - literal_only_boolean_expressions
    - no_adjacent_strings_in_list
    - prefer_const_constructors
    - prefer_const_declarations
    - prefer_final_fields
    - prefer_final_locals
    - prefer_void_to_null
    - unnecessary_await_in_return
    - unnecessary_statements
    - use_build_context_synchronously

strict-casts: true, strict-inference: true, strict-raw-types: true — three strict mode flags. strict-inference is especially important: forbids implicit dynamic where type can't be inferred.

Running in CI

- name: Analyze
  run: flutter analyze --fatal-infos --fatal-warnings

- name: Check formatting
  run: dart format --output=none --set-exit-if-changed lib/ test/

--fatal-infos turns info messages into errors. Harsh, but effective: forces developers not to ignore minor remarks.

dart format --set-exit-if-changed checks formatting without modifying files — if formatting doesn't match dart format, CI fails.

Custom Lint Rules via dart_code_linter

For deeper analysis — dart_code_linter (formerly dart_code_metrics):

# pubspec.yaml
dev_dependencies:
  dart_code_linter: ^1.1.0
# analysis_options.yaml
dart_code_linter:
  metrics:
    cyclomatic-complexity: 20
    lines-of-code: 100
    number-of-parameters: 4
    maximum-nesting-level: 5
  metrics-exclude:
    - test/**
  rules:
    - avoid-unnecessary-setstate
    - prefer-extracting-callbacks
    - avoid-returning-widgets
    - check-for-equals-in-render-methods

avoid-returning-widgets and prefer-extracting-callbacks — Flutter-specific rules that standard analyzer doesn't cover, and they directly impact rebuild performance.

Pre-commit Integration

# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: flutter-analyze
        name: Flutter Analyze
        language: system
        entry: flutter analyze
        types: [dart]
        pass_filenames: false
      - id: dart-format
        name: Dart Format
        language: system
        entry: dart format --set-exit-if-changed
        types: [dart]

Timeline: 1 day. Cost is calculated individually.