Skip to content

Instantly share code, notes, and snippets.

@gaetschwartz
Last active March 7, 2024 15:09
Show Gist options
  • Star 73 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save gaetschwartz/b5fed3ebf7594c54472c6ecf11eed2e1 to your computer and use it in GitHub Desktop.
Save gaetschwartz/b5fed3ebf7594c54472c6ecf11eed2e1 to your computer and use it in GitHub Desktop.
Nest files in Flutter projects on VSCode, inspired from https://github.com/antfu/vscode-file-nesting-config
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
"readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
"*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},
@abdullahalamodi
Copy link

I was add flutter_native_splash.yaml under pubspec.yaml you can update it

@officialismailshah
Copy link

officialismailshah commented Mar 9, 2022

it is giving me EOF error in json

@rrousselGit
Copy link

"pubspec.yaml": "[...], .dart_tool,

That doesn't seem to work, at least not for me. I don't think folders are supported here

@Moohamed-Elsayed
Copy link

That doesn't seem to work

@gaetschwartz
Copy link
Author

@rrousselGit You're totally right, I first added it as I hoped it would work, possibly in next versions, but it currently seems like folders arent supported.

@gaetschwartz
Copy link
Author

it is giving me EOF error in json

@proismailshah you need add these line inside your settings.json file, so:

{
    ".....": "You other settings",
    "explorer.experimental.fileNesting.enabled": true,
    "explorer.experimental.fileNesting.expand": false,
    "explorer.experimental.fileNesting.patterns": {
        "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
        ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
        "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
        "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
      },
    "........": "You other settings"
}

@officialismailshah
Copy link

officialismailshah commented Mar 10, 2022

it worked for me, I was adding this first in my snippet area "dart.json" file now i have added this snippet in the right json file you have to search in the VScode search bar settings.json file it will show default settings.json file select that and paste above rules inside delimeters
if it gives error then
".....": "You other settings", "explorer.experimental.fileNesting.enabled": true, "explorer.experimental.fileNesting.expand": false, "explorer.experimental.fileNesting.patterns": { "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml", ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*", "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md", "*.dart": "$(capture).g.dart, $(capture).freezed.dart", }, "........": "You other settings"

I have removed the delimeters added by the @gaetschwartz in the starting and in the end

hope it will help you....😊😊

@officialismailshah
Copy link

it is giving me EOF error in json

@proismailshah you need add these line inside your settings.json file, so:

{
    ".....": "You other settings",
    "explorer.experimental.fileNesting.enabled": true,
    "explorer.experimental.fileNesting.expand": false,
    "explorer.experimental.fileNesting.patterns": {
        "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
        ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
        "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
        "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
      },
    "........": "You other settings"
}

Thanks @gaetschwartz

@abdullahalamodi
Copy link

if your vs code did not recognize explorer.experimental.fileNesting.enabled you need to update it to the last version.

@AhmetMelihSerter
Copy link

Thanks.

@jbjason
Copy link

jbjason commented Mar 25, 2022

worked for mee.. see the location & process.. don't forget to add comma(,)

Capture

@Rajesh0667
Copy link

it really does work

@mugilan-viewzen
Copy link

as of v1.67.0, we can remove the experimental tag.

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
    "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
    ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
    "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
    "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},

@SunitRoy2703
Copy link

as of v1.67.0, we can remove the experimental tag.

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
    "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
    ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
    "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
    "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},

This worked for me!

@MuhammadSufyanMalik
Copy link

as of v1.67.0, we can remove the experimental tag.

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
    "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
    ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
    "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
    "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},

This worked for me!

Same for me :)

@abdullahalamodi
Copy link

abdullahalamodi commented Sep 8, 2022

".....": "You other settings",
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, pubspec_overrides.yaml, all_lint_rules.yaml",
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
"readme.": "authors, backers.md, changelog, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
"*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},
"........": "You other settings",

add pubspec_overrides.yaml to the list

@DVCone
Copy link

DVCone commented Dec 3, 2022

can I add that iml file to the file nesting? and how to do it?

@abdullahalamodi
Copy link

can I add that iml file to the file nesting? and how to do it?

yes, you can.
just add the file name x.iml to pubspec.yaml list in the snippet

@viveeeeeek
Copy link

as of v1.67.0, we can remove the experimental tag.

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
    "pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
    ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
    "readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
    "*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},

yup this worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment