Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search for Hardcoded String in Flutter

Tags:

flutter

How could I get all hardcoded string in Flutter?

In Android I can get it by Lint Inspection but is there any similar to that in Flutter?

I opened an issue on Flutter Repo: https://github.com/flutter/flutter/issues/42227

like image 654
amorenew Avatar asked Oct 08 '19 07:10

amorenew


1 Answers

If you're on IntelliJ, you can find all text matching a hardcoded String regex.

  1. Press Cmd + Shift + F (or Ctrl + Shift + F)
  2. Enable regex search
  3. Search for "(.*?)" or '(.*?)' depending on whether you use double-quotes or single-quotes for hardcoded strings. For both, use "(.*?)"|'(.*?)'
  4. Step 3 would only show a maximum of 100 results
  5. Press "Open in Find Window"

Steps 2-5

This should open a new Find window from the bottom with all results (3,144 in my case):

Search-results-collapsed

You can then expand the results directory and preview any hardcoded string in any file from the results:

enter image description here

like image 156
Rohan Taneja Avatar answered Sep 23 '22 13:09

Rohan Taneja