Home > Blockchain >  flutter change State name
flutter change State name

Time:02-16

In the following code, I want to change "HomePage" to "todoScreen" in every area that is relevant. How can I do that beside ctr F?

class Homepage extends StatefulWidget {
  const Homepage({Key? key}) : super(key: key);

  @override
  _HomepageState createState() => _HomepageState();
}

class _HomepageState extends State<Homepage> {
  // create a database object so ew can access db functions
  var db = DatabaseConnect();

CodePudding user response:

Renaming is a common operation related to refactoring source code and VS Code has a separate Rename Symbol command (F2). Some languages support rename symbol across files. Press F2 and then type the new desired name and press Enter. All usages of the symbol will be renamed, across files.

Example : For Macbook , click on the class name you will find this option then change the updated name .

enter image description here

CodePudding user response:

You can search HomePage class in files (there is a search icon under explorer in the left side) and replace all of them by todoScreen.

1

CodePudding user response:

In AndroidStudio (or IntelliJ for that matter):

  1. right-click the class Name in Question
  2. go to Refactor -> Rename..
  3. a window will ask you for the new name
  4. enter new name
  5. click 'Refactor'

Android Studio will then rename all references in the project accordingly, so if you rename the Stateful HomePage to MyPage it will also cleverly rename _HomePageState to _MyPageState.

Instead of using the menu, you can just , btw.

  • Related