Andriod Studio Extract widget or Extract method

5 min read

Method 1

Shortcut keys:

  • Windows/Linux: Put your cursor (光标) on the widget name and press Ctrl+Alt+M to extract it as a method or Ctrl+Alt+W to extract it as a widget.
  • MacOS: Put your cursor (光标) on the widget name and press Option+Command+M to extract it as a method or Option+Command+W to extract it as a widget.

You can also accomplish the same thing by right clicking the widget name and choosing Refactor > Extract from the context menu.

Method 2

You can also extract a widget into a method or new widget from the Flutter Outline menu.

  1. Click Flutter Outline on the top left side
  2. Select the widget in the outline
  3. Right click and choose Extract method... or Extract widget...
  4. Give it a name