Strange syntax error with flutter_localizations and intl - flutter

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.

Related

Flutter VS code plugin stuck Waiting for connection from debug service on Chrome

I am using VS Code for Flutter developement since a long time and up until now, launching the web version from VS code has worked just fine. However, similar to what others have posted I now get a "Waiting for connection from debug service on Chrome...".
The Chrome window opens but the URL just says: "http://localhost:57698/" and the page is white.
If I click reload, the URL changes to "http://localhost:57698/#/" and the page loads correctly. This seem to match other peoples experience for this problem, that hot reloading or similar loads the page.
If I launch the web version from the command line with: "flutter run -d chrome" it also works fine. It is only when launching from VSCode it no longer works (and it has been ok for 2 years). I have tried to restart the whole computer as well as Chrome and VS code and I have done flutter clean, still the same. I have also tested on 2 different computers, no change. Is there some magic thing in Chrome that can get stuck or what could have happened?
My flutter doctor says that all is ok:
[✓] Flutter (Channel stable, 2.10.5, on macOS 13.2 22D49 darwin-arm, locale en-ES)
• Flutter version 2.10.5 at /Users/johanlantz/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (10 months ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/johanlantz/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• 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.11+0-b60-7772763)
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Downgrading the dart and flutter VS code plugins from 3.58.0 to 3.56.0 fixed this (on two separate MacBooks with the same issue).
The latest version of the plugin switched to a new API (because an old API is being removed). Unfortunately when running on the web, it appears as if the new API is available (the VM Service version number is high enough), but the API is unfortunately not actually available.
A fix is on the way - you can get it early by switching to the Pre-Release version of the extension:

Flutter and Dart extensions appear to be broken on VSCode

I opened VSCode a few days ago to continue work on a Flutter project, unfortunately, the Flutter and Dart usually take a while to start(2-3 minutes), but this time,the extensions failed to initialize, and I'm left with white colourless code and no access to the tools that come with the extensions(i.e F5 for debug).screenshot of the current state of things
Over the past few days, I have,
Deleted and re-installed the Flutter SDK(forgive me, I cant remember what version it was at before, but now its 3.3.7, Dart 2.18.4)
Deleted and re-installed VSCode(used to be a snap, now a .deb)
Uninstalled and re-installed the Flutter and Dart extensions(multiple times, restarted VSCode each time)
- Ran said project directly from the terminal to be sure I had the flutter tool correctly installed(flutter run and flutter build apk ran fine, with no errors)
Please find the results of 'flutter doctor -v' below
Flutter (Channel stable, 3.3.7, on Ubuntu 20.04.5 LTS 5.15.0-52-generic,
locale en_NG)
• Flutter version 3.3.7 on channel stable at
/home/alabi/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision e99c9c7cd9 (7 days ago), 2022-11-01 16:59:00 -0700
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /home/alabi/Android/Sdk
• Platform android-33, build-tools 32.1.0-rc1
• ANDROID_SDK_ROOT = /home/alabi/Android/Sdk
• Java binary at: /home/alabi/.jdks/openjdk-18.0.1.1/bin/java
• Java version OpenJDK Runtime Environment (build 18.0.1.1+2-6)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for
more details.
[✗] Chrome - develop for the web (Cannot find Chrome executable at
google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] 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 (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup
for detailed instructions).
[✓] VS Code (version 1.73.0)
• VS Code at /usr/share/code
• Flutter extension version 3.52.0
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.5 LTS 5.15.0-52-generic
The CLI command, 'flutter --version' returns
Flutter 3.3.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e99c9c7cd9 (7 days ago) • 2022-11-01 16:59:00 -0700
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0
All of this leads me to believe the Flutter SDK is installed correctly and the problem is with VSCode and the extensions
Any help is appreciated, thank you!
Make sure that you use official extensions for Flutter/Dart. They are created by Dart Code.
Fixed!
If something in the extension is corrupt you could try uninstalling the extensions and then deleting them from ~/.vscode/extensions (the ones starting dart-code) and then reinstall.
From DartCode's GitHub, read the issue and fix here if you're still confused

Unable to run flutter for Desktop, but can build flutter for desktop (Linux)

My flutter app builds and runs just fine, but I cannot run it in debug mode.
Below is the error I get:
Unable to start executable "build/linux/x64/debug/bundle/polls": ProcessException: Failed to find "build/linux/x64/debug/bundle/polls" in the search path.
Command: build/linux/x64/debug/bundle/polls
ProcessException: Failed to find "build/linux/x64/debug/bundle/polls" in the search path.
Command: build/linux/x64/debug/bundle/polls
The app name I am working on is called polls, and when I look into the directories, the build/linux/x64/release directory has a directory called bundle with the compiled binary, but the build/linux/x64/debug doesn't have the bundle directory.
How do I make flutter run -d linux create the missing directory when compiling the debug version?
My environment configurations are as shown below:
[✓] Flutter (Channel stable, 3.0.1, on Linux Mint 20.3 5.4.0-110-generic, locale en_GB.UTF-8)
• Flutter version 3.0.1 at /usr/local/src/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (11 days ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /home/arthur/Android/Sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /usr/local/src/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• 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.1)
• Android Studio at /usr/local/src/android-studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin version 211.7817
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.67.2)
• VS Code at /usr/share/code
• Flutter extension version 3.40.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Linux Mint 20.3 5.4.0-110-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I just ran into a similar issue, where a sample flutter app, that I created via Visual Studio Code, was unable to find bundle in the path.
As a test, in a completely different directory, from a terminal outside of
Visual Studio Code, I ran flutter create startup_namer and was able to
successfully invoke flutter run -d linux on it.
I solved by running flutter clean

Vscode showing white theme/text in my flutter dart code

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!

How to run flutter test on chrome platform ? "No tests ran" when trying with starting project

In order to create a android/web app I want to run flutter tests on specific platforms. When I specify "chrome" I obtain "No tests ran." Of course app is working when I do "flutter run -d chrome"
The problem is easy to reproduce with flutter starting app. Here's what I've done on linux :
mkdir chrome_test
cd chrome_test
create .
flutter test test/
=> All tests passed!
When I add #TestOn("vm") at beginning of test/widget_test.dart
=> all tests passed!
When I add #TestOn("chrome") at beginning of test/widget_test.dart
=> No tests ran.
[✓] Flutter (Channel master, v1.10.6-pre.39, on Linux, locale fr_FR.UTF-8)
• Flutter version 1.10.6-pre.39 at /home/rbarbe/programes/flutter
• Framework revision 4815b26d71 (il y a 7 jours), 2019-09-24 00:21:44 -0700
• Engine revision 953ac71749
• Dart version 2.6.0 (build 2.6.0-dev.1.0 d53d355c6c)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/rbarbe/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /home/rbarbe/programes/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 3.3)
• Android Studio at /home/rbarbe/programes/android-studio
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] IntelliJ IDEA Community Edition (version 2019.1)
• IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/191.6183.87
• Flutter plugin version 35.2.2
• Dart plugin version 191.6183.88
[✓] IntelliJ IDEA Community Edition (version 2019.2)
• IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/192.6603.28
• Flutter plugin version 39.0.5
• Dart plugin version 192.6603.23
[✓] VS Code (version 1.38.1)
• VS Code at /usr/share/code
• Flutter extension version 3.4.1
[✓] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 77.0.3865.90
• Server • web • web-javascript • Flutter Tools
• No issues found!
Method (1)
open a terminal
go to root the directory of the project
Type this => flutter run -d chrome --web-port 2021 test/home_test.dart
or something like that
wait for chrome to jump out
see the results on the terminal!!
Note => change test/home_test.dart with your file name !.
I hope that will work for you!
if not try method (2).
maybe you will find your answer!!
method (2)
follow the steps given in the link carefully.
https://flutter.dev/docs/cookbook/testing/integration/introduction