Skip to content

📦 Import Style: Use package: Imports Instead of Relative Imports #20

@ajaxspace

Description

@ajaxspace

Problem:
Some files use relative imports (e.g. ../../shared/constants.dart) instead of package: imports. This can lead to:

  • Confusing and brittle import paths
  • Errors in deep test files or nested folders
  • Inconsistent import style across the codebase

✅ Recommendation

Use package: imports consistently throughout the project:

// ✅ Preferred
import 'package:your_package_name/shared/constants.dart';

Instead of:

// ❌ Avoid
import '../../shared/constants.dart';

📐 Bonus

You can enforce this via analysis options:

linter:
  rules:
    always_use_package_imports: true

Impact:

  • Improves readability and portability
  • Avoids import breakage during refactors or test runs
  • Promotes consistency in team workflows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions