gmlewis / flutter-stylizer

Flutter Stylizer is a VSCode extension that organizes your Flutter classes and mixins in an opinionated and consistent manner.
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
Apache License 2.0
23 stars 3 forks source link

Run stylizer on all files #23

Closed maxpill closed 2 years ago

maxpill commented 2 years ago

Hello, is there a possibility to stylize all files in a given directory at once? If not, it would be very nice to have a feature like this.

gmlewis commented 2 years ago

Yes indeed! You will want to check out the stand-alone version here: https://github.com/gmlewis/go-flutter-stylizer

maxpill commented 2 years ago

I actually tried it - it worked well. Nevertheless it would be nice to have a possibility to run it on all files via VS Code extension in example with a command. I can make a PR in my free time if you like :)

gmlewis commented 2 years ago

I actually tried it - it worked well. Nevertheless it would be nice to have a possibility to run it on all files via VS Code extension in example with a command. I can make a PR in my free time if you like :)

Yes, a PR would be great, thank you!

longtimedeveloper commented 2 years ago

@gmlewis @maxpill

I read this stack overflow: https://stackoverflow.com/questions/43666270/how-do-i-format-all-files-in-a-visual-studio-code-project

Scroll down to this part of the thread.

image

This recommends this extension Command on All Files

I followed the stack overflow and set up my settings.json to format all .dart files in my project.

"commandOnAllFiles.commands": {
    "Format File": {
        "command": "editor.action.formatDocument",
        "includeFileExtensions": [
            ".dart"
        ]
    }
}

@gmlewis - extension may allow your users to run your command on all files.

The above command that runs is editor.action.formatDocument

What is your command? If you reply here, I'll set it up and give it a try.

Best regards,

Karl

gmlewis commented 2 years ago

Cool! Thanks, Karl, for the research.

The command should be:

        "command": "extension.flutterStylizer",
longtimedeveloper commented 2 years ago

@gmlewis I just found it in the source. Sorry for randomizing you. Testing on a SMALL project first. Stand by...

longtimedeveloper commented 2 years ago

@gmlewis @maxpill

After installing this extension Command on All

Edit your settings.json

"commandOnAllFiles.commands": {
    "Format File": {
        "command": "editor.action.formatDocument",
        "includeFileExtensions": [
            ".dart"
        ]
    },
    "Flutter Stylizer": {
        "command": "extension.flutterStylizer",
        "includeFileExtensions": [
            ".dart"
        ]
    }
}

Run the command Flutter Stylizer, all .dart files will be stylized!

CRITICAL

After executing the command, wait, wait, wait, and then it will run, open every file one by one, run the command, and close the file. For large projects, take about 20 seconds to get going.

gmlewis commented 2 years ago

Thank you, @longtimedeveloper !

And just as a reminder to people finding this thread later, if you want a super-fast way to process all files in a very large project, please remember to check out the stand-alone command line companion tool: https://github.com/gmlewis/go-flutter-stylizer

longtimedeveloper commented 2 years ago

@gmlewis I'll definitely check out go-flutter-stylizer, thank you!

gmlewis commented 2 years ago

Closing this issue now that the README.md file has been updated to include this solution provided by @longtimedeveloper . Thank you, @longtimedeveloper !