flutter_i18n
flutter_i18n copied to clipboard
Exception: Write access is allowed from event dispatch thread only
There is Exception in 1.1.1.192:
Write access is allowed from event dispatch thread only
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@4499352e
Current thread: Thread[Timer-3,6,Idea Thread Group] 1535808483
SystemEventQueueThread: Thread[AWT-EventQueue-0 2019.2.3#IU-192.6817.14 IDEA, eap:false, os:Mac OS X 10.14.6, java-version:JetBrains s.r.o 11.0.4+10-b304.69 2019.2.3#IU-192.6817.14 IDEA, eap:false, os:Mac OS X 10.14.6, java-version:JetBrains s.r.o 11.0.4+10-b304.69,6,Idea Thread Group] 1266730927
at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1068)
at com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1150)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:992)
at eu.long1.flutter.i18n.files.FileHelpers.getI18nFile(FileHelpers.kt:51)
at eu.long1.flutter.i18n.workers.I18nFileGenerator.generate(I18nFileGenerator.kt:67)
at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1$lambda$1.compute(actions.kt:74)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:922)
at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1.run(Timer.kt:150)
at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
at java.base/java.util.TimerThread.run(Timer.java:506)
I'm using IDEA with multi module layout and seems that plugin tries to create res/values
folder in the root project and after fails with Exception.
My root project does not has pubspec.yaml
file.
Folder structure:
./ - main project - NO pubspec.yaml
app - flutter app
packages/my_package_1 - dart package
Each folder added to IDEA as separate module.
Plugin v1.1.2 has been published to JetBrains, awaiting approval. Could you install and check it and report back if the error still persists?
Thank you. I will check as soon as it will be approved by Jetbrains.
What about plugin behavior with such directory structure, where root directory does not contains any flutter or dart project but plugin still tries to create res/values
folder in it?
This is yet unsupported, but I think I will add an option to select both the name of the generated
folder and also where to find Arb files. Then you can easily point the plugin to the right directories.
I think that It will be better if plugin will detect generated folder name relative to the pubspec.yaml
.
Yeah, by default it will follow where the pubspec file is located -- but it may be specified by the user as well (when this is implemented).
Yeah, by default it will follow where the pubspec file is located
Is it current behavior or future behavior?
In my project structure there is NO pubspec.yaml
file in the root folder, but plugin still creates res/values
folder in the root.
Yeah, I understand that.
However, for the plugin to configure itself, it will try to load the pubspec.yaml
file from the project's root folder, even if it just contains the following:
flutter_i18n:
enable-flutter-i18n: false
Do you have a better idea on how the plugin can be configured otherwise? (without showing a dialog or a settings box.)
In pseudo-code logic should be like this:
foreach (pubspec_file in ...){
if (has(dependencies.flutter) && (has(dependencies.flutter_localizations))){
plugin_enabled = true
} else {
plugin_enabled = false
}
if (has(flutter_i18n.enable-flutter-i18n)){
plugin_enabled=${flutter_i18n.enable-flutter-i18n}
}
res_values_folder=dirname(pubspec_file)+'/res/values'
src_folder=dirname(pubspec_file)+'/lib'
}
Don't forget that IDEA can have multi-module project.
Multi-module is not yet supported, unsure what's the best approach right now. About the pseudo-code: that's how it works now ;)
So, what about multi-module project support? Actually, in my case I moved flutter app to the app
dir of the root project and plugin does not work :(
As expected. Plugin searches for pubspec.yaml in the root folder only.
Do you have any plans to add subfolder/submodule support?
Multi-module is not yet supported, unsure what's the best approach right now. If you have an idea on how this can be accomplished, please share.