Code D. Monkey
Code D. Monkey

Reputation: 43

Flutter Extract Method vs. Extract Widget vs. Extract Flutter Widget in androidStudio

Hi I'm new to Flutter and I have several questions regarding Extract Method and Extract Widget in Android Studio.

  1. When it comes to making code clean and reusable, what is the difference between Extract Method and Extract Widget? When do I know what to use? It seems they both work fine to me.

  2. If I Right click on a Widget that I want to extract and go to Refactor -> Extract Flutter Widget then it works, however if I Left click on a Widget to focus and use the hotkey Command+Option+W, it doesn't work. Why is it happening? Moreover if I go to Flutter outline -> select the Widget -> Right click -> Extract Widget then it shows the same result. What's the difference between Extract Flutter Widget and Extract Widget?

Thank you.

Upvotes: 4

Views: 3472

Answers (2)

Mayowa Philip
Mayowa Philip

Reputation: 1

For testability and performance. use extract widget.

Upvotes: 0

Shehzad Hussain
Shehzad Hussain

Reputation: 36

If you want to show a widget use the Extract widget and method is basically a function needs to be executed basically logical part. You can do same by return the widget in methods but it's not a right choice as per performance basis.

But if you are a beginner then it's ohkk to use for now.

This comment is basically posted by Satyarth Mittal.

Upvotes: 2

Related Questions