This shortcut works with Android Studio on Mac. See this article for shortcuts on Windows: juejin.cn/post/684516…
Quickly create a new Stateless or Stateful component
To create a new Stateless component, type stless and press Enter:
To create a new Stateful component, type stful, press Enter:
To create a new animation component, type Stanim and press Enter:
There are other shortcuts, which are not described here. These shortcuts are available in Preferences -> Editor -> Live Templates:
Dart and Flutter shortcuts can also be modified. The above shortcuts import packages and comments directly and are added by myself. They are not included by default:
To customize the shortcut keys, select Flutter, click the + sign in the upper right corner, select Live Template, enter the name and generated code, and click OK.
The warning appears at the lowest level. Select Dart and click OK.
Use the same method, test, press enter.
File And Code Templates
When you create the Dart File, generate the default Code, open Preferences -> Editor -> File And Code Templates, And check the Files TAB on the right. It is empty by default
Add auto-generated code:
import 'package:flutter/material.dart';
///
/// des:
///
class ${NAME} extends StatelessWidget {
@override
Widget build(BuildContext context) {
returnContainer(); }}Copy the code
To create a home_page DART file:
The newly created DART file automatically generates the preset code.
Formatting code
Shortcut keys: Option + Command + L
Clearing useless references
Shortcut: Control + Option + O (letter O key)
Forward/back cursor position
When tracing code, it is common to jump to other classes. Back shortcuts: Option + Command + direction left key, forward shortcuts: Option + Command + direction right key,
View the inheritance relationship of the current class
Shortcut key: Control + H
Note: If you select Container in build, pressing the shortcut key does not work. You must go to the Container source code and select the Container class name.
annotation
Single-line comment: command + /.
/**/ : option + command + / or select multiple lines: command + /
Find references
Select the class or method you want to find and press command + G to pop up a list of references at the bottom.
Automatic import package
Shortcut key: Option + Enter, select the correct package.
Automatic positioning
When entering a code file on the right, navigate to the file on the left and select Autoscroll to Source and Autoscroll from Source in the Project TAB Settings.
Notice the change in the project TAB on the left.
Current file search
Shortcut keys: Command + F
Global search
Shortcut keys: Command + Shift + F
Search files:
Shortcut: Click Shift twice
Automatically generate constructors:
Select the final parameter and the shortcut key: Option + Enter
Add a parent component, become a child component, and delete a child component
Shortcut key: Option + Enter
You can add Center, Padding, Column, and other parent components to the current component.
You can also delete or move a component.
View the UI outline
Open the Flutter Outline TAB
You can see the UI structure clearly.
Extract the code into the method
Open the Flutter Outline TAB and click on the icon of the right arrow:
Flutter Resources website
- Liverpoolfc.tv: flutter. Dev /
- Chinese language: FlutterChina.club /
- Flutter Chinese community Resources: Flutter -io.cn/
- Pub (domestic) : pub. Flutter – IO. Cn /
- Pub: pub. Dev /
- DartPad:dartpad.dartlang.org/
- Dart official website: dart.dev/
- CodePen: CodePen. IO /
- Json to entity class: javiercbk.github. IO /json_to_dar…
The last grand recommend my blog: laomengit.com/flutter/wid… Contains 330 articles detailing the use of Flutter components and the Flutter combat series.
communication
Old Meng Flutter blog address (330 controls usage) : laomengit.com