Flutter-intellij: Incorrect package renaming when moving file to another directory

Created on 5 Aug 2020  Â·  3Comments  Â·  Source: flutter/flutter-intellij

Step1. Move file "code_panel.dart" to another directory

step1

Step2. Click "OK" in popup window

step2

Step3. Incorrect import renaming

step3

flutter doctor -v

[√] Flutter (Channel master, 1.21.0-6.0.pre.169, on Microsoft Windows [Version 10.0.18363.535], locale en-US)
    • Flutter version 1.21.0-6.0.pre.169 at c:\flutter
    • Framework revision 0e558042d7 (24 hours ago), 2020-08-04 11:36:04 -0400
    • Engine revision 033dd45607
    • Dart version 2.10.0 (build 2.10.0-2.0.dev 0f0e04ec3a)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\ilopX\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\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

[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.4.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
    • Visual Studio Enterprise 2019 version 16.4.29613.14
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\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)

[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.7361

[√] Connected device (3 available)
    • Windows (desktop) • windows    • windows-x64    • Microsoft Windows [Version 10.0.18363.535]
    • Web Server (web)  • web-server • web-javascript • Flutter Tools
    • Chrome (web)      • chrome     • web-javascript • Google Chrome 84.0.4147.105

• No issues found!

bug topic-editing

All 3 comments

/fyi @scheglov

I can confirm this for Dart/Flutter projects. It has always done this. It is not new.

An interesting detail is that the result varies:

  1. If the file being moved, is referenced elsewhere with a relative path name in it's import, then the rename for the move works correctly!

  2. If the file being moved, is referenced elsewhere with a package import, like in the above example, then the rename fails and it gets a weird file reference like above. It should in that case keep the packages reference with the path corrected.

This leads to the following issues,

  • Hot Reload doesn't work for the code in that particular file.
  • If the code is opened on a different PC it'll show an error as the path is relative to the system.
Was this page helpful?
0 / 5 - 0 ratings