flutter_semantic_lints 0.1.2 copy "flutter_semantic_lints: ^0.1.2" to clipboard
flutter_semantic_lints: ^0.1.2 copied to clipboard

Custom lint rules that detect meaningless, conflicting, or no-effect Flutter code.

flutter_semantic_lints #

pub.dev

English | 日本語 | 한국어 | Tiếng Việt | 中文

Not style. Not formatting.

This package detects meaningless Flutter code.


Why this exists #

Most lint packages focus on:

  • style
  • naming
  • best practices

But they miss something critical:

Code that works but makes no sense.

This package detects:

  • conflicting parameters
  • useless parameters
  • no-effect widgets

Rules #

box_decoration_color_gradient #

Bad:

BoxDecoration(
  color: Colors.red,
  gradient: LinearGradient(...),
)

color is ignored.

Good:

BoxDecoration(
  color: Colors.red,
)

Good:

BoxDecoration(
  gradient: LinearGradient(...),
)

Use either color or gradient, not both.

container_color_decoration #

Bad:

Container(
  color: Colors.red,
  decoration: BoxDecoration(...),
)

color conflicts with decoration.

Good:

Container(
  color: Colors.red,
)

Good:

Container(
  decoration: BoxDecoration(
    color: Colors.red,
  ),
)

Move the color into decoration when using decoration.

expanded_flex_one #

Bad:

Expanded(flex: 1)

Default value is already 1.

Good:

Expanded(
  child: child,
)

Good:

Expanded(
  flex: 2,
  child: child,
)

Omit flex when the value is 1.

opacity_one #

Bad:

Opacity(
  opacity: 1.0,
  child: ...,
)

No visual effect. Adds cost only.

Good:

child

Good:

Opacity(
  opacity: 0.5,
  child: child,
)

Remove Opacity when the value is 1.0.

Installation #

dev_dependencies:
  custom_lint:
  flutter_semantic_lints:

Setup #

analyzer:
  plugins:
    - custom_lint

Run #

dart run custom_lint

Philosophy #

  • correctness over style
  • semantics over formatting
  • signal over noise

Rule Categories #

conflicting_parameter #

  • box_decoration_color_gradient
  • container_color_decoration

useless_parameter #

  • expanded_flex_one

no_effect_widget #

  • opacity_one

Testing #

The example project doubles as integration coverage.

cp example/analysis_options.custom_lint.yaml example/analysis_options.yaml
cd example
dart run custom_lint

Positive cases use // expect_lint: comments. Negative and edge cases live in separate example files and should stay quiet.

Non-goals #

  • style lint
  • naming rules
  • formatting
  • architecture opinions

Status #

MVP

Implemented rules:

  • BoxDecoration conflict
  • Container conflict
  • Expanded(flex: 1)
  • Opacity(1.0)

Contributing #

Only submit rules that:

  • are objectively correct
  • have near-zero false positives
  • are explainable in one sentence

License #

MIT

0
likes
0
points
278
downloads

Publisher

verified publishershinriyo.com

Weekly Downloads

Custom lint rules that detect meaningless, conflicting, or no-effect Flutter code.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, custom_lint_builder

More

Packages that depend on flutter_semantic_lints