0

When auto importing in Android Studio, I get the full path to the file instead of the relative or package prefixed path.

For example:

import 'C:\/Dev/flutter/packages/flutter/lib/material.dart';

This obviously does not work when you are collaborating and checking in code.

What I am expecting:

import 'package:flutter/material.dart';

The auto-import also generates relative paths to files in the dart project's lib/ directory. However I would rather prefer the behavior revert back to generating 'package:/' in case I re-organize some of my files.

What settings need to be set so the auto import will generate import 'package:...'? I don't see anything in the File --> Settings --> Editor --> General --> Auto Import that helps address this problem.

Including environment information below:

> flutter doctor --verbose
[√] Flutter (Channel unknown, v1.13.5, on Microsoft Windows [Version 10.0.18362.592], locale en-US)
    • Flutter version 1.13.5 at C:\Dev\flutter
    • Framework revision 41a911099b (5 weeks ago), 2019-12-19 13:48:02 -0800
    • Engine revision 0f90e6546b
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 aa6709974d)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\USERNAME\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Dev\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.5)
    • Android Studio at C:\Dev\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
4

1 回答 1

1

我最终升级到更新的 beta 版本,它解决了这个问题。

> flutter doctor --verbose

[√] Flutter (Channel unknown, v1.14.6, on Microsoft Windows [Version 10.0.18362.592], locale en-US)
    • Flutter version 1.14.6 at C:\Dev\flutter
    • Framework revision fabeb2a16f (12 days ago), 2020-01-28 07:56:51 -0800
    • Engine revision c4229bfbba
    • Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\USERNAME\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\DevTools\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.5)
    • Android Studio at C:\Dev\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
于 2020-02-09T08:22:50.787 回答