Vscode showing white theme/text in my flutter dart code - flutter

In the image above you can see that the whole dart code is showing white lines and this happened after my laptop accidently turned off while I was running the code.
The first error it gave was corrupted .git/packed-ref file which i fixed but this one isn't going away, other file type is showing their repective color theme only the .dart file is doing this. and also dart analyzer isn't working too
//Flutter doctor -v
[√] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 6.3.9600], locale en-US)
• Flutter version 2.8.0 at D:\flutter\Sdk\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cf44000065 (8 weeks ago), 2021-12-08 14:06:50 -0800
• Engine revision 40a99c5951
• Dart version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2)
• Android SDK at C:\Users\bright\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0-rc2
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.63.2)
• VS Code at C:\Users\bright\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.34.0
[√] Connected device (1 available)
• Edge (web) • edge • web-javascript • Microsoft Edge 97.0.1072.69
! Doctor found issues in 1 category.
I don't exactly know what the problem is, since it isn't showing me any error. Please what do i do?

I think there is something wrong with the Dart extension (perhaps some files are corrupt), but uninstalling/re-installing it does not remove the files from disk and re-download it.
I would try uninstalling the Dart extension, then go into your %USERPROFILE%\.vscode\extensions folder and delete any dart-code.dart-code folders, and then re-launch VS Code and re-install it.
If that doesn't solve it, please file an issue at https://github.com/Dart-Code/Dart-Code. Thanks!

Related

**flutter_blue_plus** This version of %1 is not compatible with the version of >Windows you're running. What should I do?

So this project of mine had flutter_blue plugin in it. And I just switched to flutter_blue_plus. And now I can't run it on my system. And this is the error it shows. And when I checked, it feels like no one else is facing this issue. There's no mention on the flutter_blue_plus package issue list either. And i found some of the similar kind of problems on stackOverflow from years ago. And it seems like they're just android problems. And I'm not an android developer. Another known flutter developer faced the same issue with the original flutter_blue package on M1 pro. And on his device, flutter_blue_plus runs properly. I'm using Windows 11 for my development.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':flutter_blue_plus:generateDebugProto'.
java.io.IOException: Cannot run program "E:\Dev\Gradle\caches\modules-2\files->2.1\com.google.protobuf\protoc\3.18.0\61d7f5d8849eb1c9b86ff07ca3f6172ce904ed4\protoc-3.18.0-osx->x86_64.exe": CreateProcess error=216, This version of %1 is not compatible with the version of >Windows you're running. Check your computer's system information and then contact the software >publisher
I've tried the basic steps, like cleaning and rebuilding project. And here is the device speceficaiton im using.
flutter doctor -v.
[√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.22623.1245], locale en-US)
• Flutter version 3.7.0 on channel stable at C:\SDK_FILES\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (6 days ago), 2023-01-23 16:55:55 -0800
• Engine revision b24591ed32
• Dart version 2.19.0
• DevTools version 2.20.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\SDK_FILES\Android_Studio_Components
• Platform android-33, build-tools 33.0.1
• ANDROID_HOME = C:\SDK_FILES\Android_Studio_Components
• Java binary at: C:\SDK_FILES\Android\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• 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 Community 2022 17.3.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.3.32825.248
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2022.1)
• Android Studio at C:\SDK_FILES\Android
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[√] VS Code (version 1.74.3)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.58.0
[√] Connected device (4 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22623.1245]
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.120
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.61
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
If someone is facing this problem. Or anything that looks familiar to it. You can try checking your gradle.properties file inside your projects android folder. And if there's any line that looks like this
protoc_platform=osx-x86_64
Try removing it.
To my little bit of understanding it's just saying the gradle system to look for the macOs operating system while creating the protoc buffer. And it's not finding it bcz the platform is windows. At least in my case, it was. It can be vice versa.

Strange syntax error with flutter_localizations and intl

Recently (today) I tried to create an app for web and desktop with Flutter and wanted it to be in multiple languages (English, French, Arabic, Dutch...) so I looked at Flutter's tutorial and followed every steps it had. And just after finishing the last step I had it working ! I could add text in, English in the app_en.arb file and in any other language in app_fr.arb by example. When I hot reloaded/restarted my app the Dart files it generates are rebuilt. But now when I do that I have an error that I couldn't find anywhere else on Internet:
Exception: Found syntax errors.
And the dart files for localization weren't rebuilt. Now I must use the
flutter gen-l10n
command to rebuild my language files.
Note:
Here's my flutter doctor:
[✓] Flutter (Channel master, 3.7.0-10.0.pre.33, on Fedora Linux 37 (Workstation Edition) 6.0.12-300.fc37.x86_64, locale fr_FR.UTF-8)
• Flutter version 3.7.0-10.0.pre.33 on channel master at /home/theskyblockman/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cee3e6cc3d (il y a 8 heures), 2022-12-17 04:03:24 -0500
• Engine revision b107699980
• Dart version 3.0.0 (build 3.0.0-35.0.dev)
• DevTools version 2.20.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /home/theskyblockman/Android/Sdk/
• Platform android-33, build-tools 33.0.0
• Java binary at: /home/theskyblockman/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[✓] Android Studio (version 2021.3)
• Android Studio at /home/theskyblockman/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738
• Flutter plugin version 71.0.3
• Dart plugin version 213.7433
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] IntelliJ IDEA Community Edition (version 2022.2)
• IntelliJ at /home/theskyblockman/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/222.4459.24
• Flutter plugin version 71.0.5
• Dart plugin version 222.4459.16
[✓] VS Code (version 1.74.0)
• VS Code at /usr/share/code
• Flutter extension version 3.54.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Fedora Linux 37 (Workstation Edition) 6.0.12-300.fc37.x86_64
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5464.2 dev
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
it's me again, this looked like a PATH problem in my case. Now that I restarted my computer I don't have the error anymore, I should have checked that before. But as I never saw this error before you should check other things like dependencies versions or your Dart and Flutter SDKs, I am not sure about how it happened so restart your computer and check a lot of things could help fix the problem.
In my case this error had appeared after I renamed the folder where project files was. I fixed all paths with old folder name, but the error was still persist. flutter clean didn't help.
Then in folder named .idea I found few files (.xml and .iml extensions) that contained the old folder's name. After I fixed it the error was gone. Hope will help.

Flutter Windows Application fails to compile

I want to debug the flutter demo application on windows x64 device.but it always fails with 1 error and 1 warning this is my Debug console :
Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
F:\flut\flutter_application_5\windows\runner\utils.cpp(52,43): error C2220: warning treated as error - no 'object' file generated [F:\flut\flutter_application_5\build\windows\runner\flutter_application_5.vcxproj]
F:\flut\flutter_application_5\windows\runner\utils.cpp(52,43): warning C4018: '>': signed/unsigned mismatch [F:\flut\flutter_application_5\build\windows\runner\flutter_application_5.vcxproj]
Exception: Build process failed.
and here is my flutter doctor log :
[flutter] flutter doctor -v
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1826], locale en-US)
• Flutter version 3.0.5 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (6 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\MEMPHIS\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.1.0)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
• Visual Studio Enterprise 2019 version 16.1.28917.181
• Windows 10 SDK version 10.0.17763.0
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] VS Code (version 1.70.2)
• VS Code at C:\Users\MEMPHIS\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.46.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1826]
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.102
• Edge (web) • edge • web-javascript • Microsoft Edge 104.0.1293.63
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
exit code 0
I can debug the demo app on edge, chrome, android without any problem
so What wrong?
The (Microsoft) C++ compiler is raising a warning inside the utils.cpp file:
windows\runner\utils.cpp(52,43): warning C4018: '>': signed/unsigned mismatch
It's configured to treat warnings as errors, so the compile fails with:
windows\runner\utils.cpp(52,43): error C2220: warning treated as error - no 'object' file generated
I don't believe that /WX (warnings as errors) can be configured other than by the build script (which turns it ON).
I suspect one of two things:
The Enterprise edition of the compiler (which you have) is slightly more picky than the Community edition (which I have). You could edit the project file to turn off warnings-as-errors, or add an exception for this warning (more below).
Your compiler needs upgrading. I've got 16.11.something; you've got 16.1.something. Run the Visual Studio Installer again to upgrade it. (For example: I just ran it, and it's suggesting I upgrade from 16.11.10 to 16.11.18...).
Editing the project file
The winapp.vcxproj project file is (apparently) generated by CMake. Edit windows\CMakeLists.txt and change the following line:
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
Make it look like this:
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100" /wd4018)
I don't know where the quotes come from; you might need them. Alternatively, remove the /WX bit.

VsCode Dart code highlighting wrong colors

I have a very strange issue. After upgrading Flutter yesterday to the newest version, my syntax highlighting is awfully off. When I open a file, everything seems fine, but as soon as the file is analyzed and the result is used for highlighting, everything breaks.
Correct (for 1-2 seconds after opening the file):
Wrong (after around 2 seconds):
I am using the Monokai Theme for VsCode. I would love to get my old coloring back, as I think the new scheme is outrageously difficult to look at.
My Flutter Doctor outpu (All versions etc.):
[flutter] flutter doctor -v
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.867], locale en-NZ)
• Flutter version 2.0.3 at R:\Programme\Flutter
• Framework revision 4d7946a68d (3 days ago), 2021-03-18 17:24:33 -0700
• Engine revision 3459eb2436
• Dart version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at R:\Programme\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: R:\Programme\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at R:\Programme\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.2
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
[√] VS Code, 64-bit edition (version 1.54.3)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90
• Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.57
• No issues found!
exit code 0
Any help would be greatly appreciated :)
Add "editor.semanticHighlighting.enabled": false in your vscode settings.json

Problem with AltGr key in flutter Windows desktop

In any Flutter app in a TextField widget, on Windows, pressing once the AltGr key will drive Windows keyboard crazy: after pressing AltGr, Windows behaves as if the ctrl key was pressed continuously in any application. (Pressing a simple v behaves like if the ctrl-v was pressed) Just double-pressing the left ctrl key will stop this strange state.
Thus, no Windows application written in flutter can be published because if the user presses the AltGr key, he will not understand why his keyboard will not work in any other application afterwards.
It can be reproduced every time, in every environment. On other Windows too. On other machine too. In release exe version too. E.g. in StaleFulWidget, and a TextField in it.
Could somebody help me to solve this very serious Flutter bug? Thank you in advance.
Windows version: Win 10 Pro 20H2 (build:19042.870) Hungarian version. In Hungarian keyboard the # key is AltGr+v. So users can not type any email address.
Flutter versions:
Flutter is already up to date on channel beta
Flutter 2.1.0-12.2.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 5bedb7b1d5 (6 days ago) • 2021-03-17 17:06:30 -0700
Engine • revision 711ab3fda0
Tools • Dart 2.13.0 (build 2.13.0-116.0.dev)
Flutter doctor is perfect.
C:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel beta, 2.1.0-12.2.pre, on Microsoft Windows [Version 10.0.19042.870], locale hu-HU)
• Flutter version 2.1.0-12.2.pre at C:\flutter
• Framework revision 5bedb7b1d5 (6 days ago), 2021-03-17 17:06:30 -0700
• Engine revision 711ab3fda0
• Dart version 2.13.0 (build 2.13.0-116.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\zsmik\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.9.31112.23
• Windows 10 SDK version 10.0.18362.0
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.870]
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90
• Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.57
• No issues found!
As of December 6 2021, this is fixed on the master channel.
If you don't want other projects to be affected, you can use https://pub.dev/packages/fvm to use that channel on a per-project level:
activate the tool, running dart pub global activate fvm in your project directory
run fvm use master
run your app using fvm flutter run, or specify the flutter SDK symlinked in your project folder within the ".fvm" directory for your IDE to use for compiling the app.