Flutter — Visual Studio Code Shortcuts for Fast and Efficient Development
Get link
Facebook
X
Pinterest
Email
Other Apps
-
Visual Studio Code Shortcuts for Fast and Efficient Development
It
is a well known fact that keyboard shortcuts can help us a lot while
developing, especially when you have a lot of code to go through and you
have to find the opening and closing brackets or insert a new widget or
remove one. Time is precious and I find these shortcuts help me a lot
in coding in flutter. I became a fan of VS Code mainly because it’s so
light weight and opens much faster than other IDEs I have worked with
and have a ton of features and customizations along with extensions
which can do wonders (This is just my personal opinion).
If you use Android Studio and IntelliJ in Windows, I would recommend you to read this great article or if you use mac you can check out this article.
First of all I hope you have Dart and Flutter Extensions enabled, if not you can get them from here : Dart and Flutter.
Now let’s jump into the shortcuts and see what all wonders we can do.
Keyboard Shortcut List
Firstly, I will provide you the shortcut to get all the shortcuts.
I
won’t be able to explain all the default shortcuts in this article
since the list is huge. You can find the list of default keyboard
shortcuts and also search for shortcuts by using CTRL+K+S as seen below:
Or you can also use Ctrl+Shift+P to Show Command Palette with the recently used commands or also to search commands.
Or you can take a printout of all the default VS Code keyboard shortcuts from here. You can get the official dart custom shortcut list from here and flutter vs code extension documentation.
Code Assist or Code Completion
While
coding, this is one of the important tools especially for beginners or
if you get stuck somewhere and want to check for options, you can use Ctrl+Space to get a list of curated code completion options.
Quick Fix or the Magic Wand
For faster development in flutter you can use the quick fix tool with is Ctrl+.
, it helps in fixing the code with some additional requirements without
messing with your code or your widget structure and giving you less
headache of manually correcting everything. Let’s see some of the
examples
Quick Fix Options
As you can see below, when on any widget you can click Ctrl+. to find the quick fix options.
Let’s explore the menu items one by one :
1. Extract Local variable
You
can extract an existing widget and make it a local variable and
magically the widget will be replaced by the variable, wherever it is
used.
2. Extract Method
What
if you have got a lot of code and you want to split it to different
methods. It would even given you a generated name for whatever code you
want to split.
But
I would advice against splitting widgets to methods, instead you should
create a new class as it has a lot of impact on performance, you could
refer this article to know in depth why widgets should not be split into methods. You can do this easily using the next menu.
3. Extract Widget
This
can come a lot in handy if you want to split your widgets into smaller
widgets. Hope by now you know about the importance of splitting widgets
to smaller widgets and it’s impact on performance π.
Just click on any widget and then click Ctrl+. and click Extract Widget option and give a name for the new widget and click Enter and that’s it.
4. StatelessWidget to StatefulWidget
Now let’s say, you wanted a StatefulWidget, but this process only gives you a StatelessWidget, but there is a cool way to convert the StatelessWidget to StatefulWidget, may be by this time you would have guessed it…
Yes, you just have to click the StatelessWidget and click Ctrl+. and then “Ta Da” as if it’s magic you will get an option Convert to StatefulWidget click on that and that’s it π
click on that and that’s it π
5. Add padding
Adding padding to an existing widget is much more easier with the quick assist tool, just select Add padding and you will get padding around your widget without messing up your widget structure.
6. Center widget
This is used to wrap it with a center widget, thus centers your widget.
7. Wrap with Column, Container, Row, StreamBuilder, new Widget
You
can use this same technique to wrap your required widget with a Column
or Container or Row or StreamBuilder or any other widget or even custom
widgets, to make that as your parent widget of the required widget.
But,
unlike the same tool in android studio, you cannot select multiple
widgets to come under a column, as of now that feature is not available.
You can also wrap with any other widget or a custom widget.
ANTARCTICA IS The MOST ALIEN PLACE ON EARTH Today at Hello Guys, I want to tell you some mysterious things about Antarctica. Antarctica which is the coldest continent in the world and is in the south pole. I want to tell you something about it today. Because Antarctica Puri has become a mysterious place for the world. Even today the whole world sees him with mysterious eyes. Antarctica is so cold because the sun does not reach there. Very few suns are able to reach there. Because Antarctica is a continent inhabited by earth. Therefore it is very difficult to reach the sun's rays there. That's why Antartica is such a cold and snow-covered continent. 70 percent pure water of the world is found in Antarctica. Under the ice of Antarctica we get to see many rivers. The largest of which is the river Vostak. Which is considered to be the largest river in Antarctica, and within the waters of these rivers we find many and different creatures. Different fis
THINKING BRAIN Power of brain What is Thinking? Thinking means thinking what does a person think? What is his power to think? How does he think Think it is good or bad. Man's thinking makes him a good person and a bad person. If a person has a good idea, he will get good results. If you have a bad idea, then bad thinking will bear fruit. Thinking means, humans can think as well as animals can think. Anyone can think of anything. But human mind is one such thing which is very powerful. We humans do not even know how powerful our mind is. Our brain can think of everything. What we would never have imagined, that mind can do everything that we would never do anything in our life. This is called thinking, if humans start using their brains. A person will be so advanced that he himself can think what he is. Albert Einstein Now we talk about the brain of human mind that the brain of a human is a very powerful brain. We humans use our brains very rare
HUMAN TECHNOLOGY Human Augmentation Human technology means which technology has been developed by humans. After the 17th century and the 18th century, humans have made great progress in the field of technology, and science in the 19th and 20th centuries. They have discovered such technology. Human beings have discovered one to one technology. Which is very possible to think in today's time. Because there are such technologies made by humans, which we think is made by an alien. Humans have worked very hard. For these technologies and these technologies have changed our entire world. In today's time, this technology is very useful for us humans. Due to today's technology, we humans have a very deep impact in our lives. They have made a very good impact in the lives of us humans. The technology of this time is very inspiring for humans. Because of that technology, we get a lot of knowledge and information. Which is very beneficial for our brain. B
Comments
Post a Comment