I have recently switch from Android Studio to VS Code to work on my Flutter projects but I have an issue with it.
VS Code keeps adding "prefix0." before all classes as soon as I am using auto-completion and I didn't find a way to get rid of it.
I have seen that some VS extensions for CSS can auto-prefix some parts of code but I do not have any CSS extensions.
Thanks
It's a bug in Dart Code that happened because it failed to understand another import already exported the class used.
A typical example is, flutter/material.dart was already imported. But by typing Widget, it'd import flutter/widget.dart and with a prefix.
https://github.com/Dart-Code/Dart-Code/issues/1847
This has been fixed. Upgrading your Dart Code and flutter SDK should fix the issue.
The issue is caused by there being one or more duplicates of class names. Check that you do not have classes with the same name imported that may conflict with each other.
Related
Many tutorials recommend using awesome flutter snippet extension by Neevash Ramdial.
But i cannot find it in the VSC extension marketplace no more!
You guys having problem with this as well?
While trying to update the project with Flutter 3 support, the organization was accidentally deleted due to a tooling bug.
The plugin has since been reuploaded to the VSCode marketplace, but users will need to reload the extension since the IDs are different.
Very sorry for the inconvenience caused here 💙
Link: https://marketplace.visualstudio.com/items?itemName=Nash.awesome-flutter-snippets
-- Nash
Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development by eliminating most of the boilerplate code associated with creating a widget. Widgets such as StreamBuilder and SingleChildScrollView can be created by typing the shortcut streamBldr and singleChildSV respectively.
It is built-in in Android Studio/VsCode. You can try by using short keyword like when you'll create StatefulWidget you can type stf and it give you hint as StatefulWidget.
I'm working on a Web/Windows/Android app and to play a soundbite I am using just_audio. However, just_audio for windows is deprecated.
To work around this I want to use Dart_VLC for windows only. However, if it is imported at all, the app will crash with the following error (full trace https://pastebin.com/qNrW3ghK):
LateInitializationError: Field 'dynamicLibrary' has not been initialized.
I've found that conditional imports resolve this to an extent.
import 'metronome_finder.dart'
if (dart.library.io) 'windows_metronome.dart'
if (dart.library.js) 'generic_metronome.dart';
This (and an abstract, two classes, and a stub) works for Web/Windows. However, on android, it appears dart.library.io is loaded and dart_vlc will be imported as well, crashing the app with the above error. Is there a way to import the windows metronome only on windows (and thus dart_vlc) and generic on all other platforms?
Alternatively is there another cleaner way to resolve this issue?
I've also asked this question on reddit and thanks in part to /u/bsutto there is now a solution (or a workaround).
I've written an example based on my own project. The core revelation here is that the import of dart_vlc breaks compilation on web, but the initialization of dart_vlc crashes during runtime. As a result it is possible to use conditional imports to direct web towards just_audio; and a runtime Platform.isWindows check to redirect android to JustAudio.
The major downside to this is that the entirety of dart_vlc is compiled into the andoird app as well, I think. Please correct me if I am wrong.
I am new to Flutter, and want to run the Flutter Official Samples in Visual Studio Code, but didn't prevail. For example, I managed to copy paste the banner codes into VS code, but it shows error in the second import statement:
import 'package:flutter/material.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
I even tried to copy-paste the whole gallery directory from the GitHub samples to the .pub-cache, but still cannot compile the codes properly.
Does anyone know how to solve my problem?
Really appreciate.
Best Regards,
Brad
I posted the question on github flutter as a feedback, and a gentleman called VladyslavBondarenko gave me a hint, and finally I figured out how to run the samples: just download the whole official samples from https://github.com/flutter/samples/blob/master/INDEX.md, and then open some of the folders in VS code, and you will be able to compile and run the samples.
However, the compiler complains that there are lots of deprecated APIs used in the codes, which means some of the codes are not updated to the latest version.
I'm coding Dart/Flutter in VSCode.
How to fix the problem where VSCode did not rename all import when I rename .dart file?
Is this the extensions bug or it's an unimplemented feature?
This is an unimplemented feature.
Originally the APIs in VS Code and the Dart analysis server were not compatible (VS Code would only tell us after the file was renamed, but the Dart server needed to know before the rename to create the correct edits).
This has recently changed - VS Code now has APIs that allow us to hook into the rename before it happens, but it hasn't been implemented in the Dart extension yet.
For notification when it is implemented, you can subscribe to this Dart-Code issue (otherwise, it'll be included in the release notes when it's done).
Does VS Code inherently come with any tool other than Ctrl+Shift+O to view the entire class hierarchy within a project? Think similar to a Visual Studio solution or Eclipse project.
I've looked around the VS Code extension marketplace and have not seen one. It would be very useful to see this kind of tree for a TypeScript based project instead of seeing just the imports from a particular .ts file
If anyone knows of one, please share!
If you're in the Explorer, the built-in OUTLINE view does exactly this. I am apparently not paying attention.