Skip to content

Code navigation doesn't work correctly for conditional imports  #3071

@osaxma

Description

@osaxma

Describe the bug

In VS code, conditional imports breaks code navigation (i.e. pressing cmd+click) and linting (i.e., showing error for invalid paths) as shown below:

import 'package:file_picker/file_picker.dart'; // cmd+click ✅  lint ✅  
import 'image_cropper/cropper_stub.dart' // cmd+click ❌  lint ✅  
    if (dart.library.io) 'image_cropper/cropper_mobile.dart' // cmd+click ❌  lint ❌
    if (dart.library.html) 'image_cropper/cropper_web.dart'; // cmd+click ❌  lint ❌

Versions (please complete the following information):

  • VS Code version: 1.52.1
  • Dart extension version: v3.18.1
  • Dart/Flutter SDK version: v3.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions