What is a legit .gitignore for a Flutter project that is developed in Android Studio?
Solution 1
This is the .gitignore generated automatically by Android Studio, hope that this is what you're looking for:
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Visual Studio Code related
.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
/build/
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Solution 2
Here is Consistent .gitignore
for Dart and Flutter projects all Editors
- Android Studio
- VisualStudioCode
- Xcode
https://github.com/flutter/flutter/issues/13892#issue-285842688
Solution 3
VSCode provides this and is equally good as the android studio version
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Web related
lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
Solution 4
You can find it in official project of flutter on Github here:
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Visual Studio Code related
.classpath
.project
.settings/
.vscode/
# Flutter repo-specific
/bin/cache/
/bin/internal/bootstrap.bat
/bin/internal/bootstrap.sh
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/devicelab/ABresults*.json
/dev/docs/doc/
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version
analysis_benchmark.json
# packages file containing multi-root paths
.packages.generated
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/.last_build_id
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/ephemeral
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# macOS
**/macos/Flutter/GeneratedPluginRegistrant.swift
# Coverage
coverage/
# Symbols
app.*.symbols
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
Here are just some points to note when making changes to the .gitgnore
file to ensure Git is always tracking the right files.
- Make changes in
.gitignore
file. - Run
git rm -r --cached .
command. - Run
git add .
command
Related videos on Youtube
dazza5000
Freelance Android Engineer. Co-organizer of the Austin Android Developer Meetup! Name is Darran Kelinske. love.
Updated on July 09, 2022Comments
-
dazza5000 almost 2 years
What is a legit .gitignore for a Flutter project that is developed in Android Studio?
This is what I have so far, but when I open up the project in Android Studio I am unable to enable Dart Support or browse the project.
#flutter specific .flutter-plugins .DS_Store .dart_tool/ .packages .pub/ build/ android/app/google-services.json .idea/ android/key.properties pubspec.lock doc/api/ #ios specific ios/.generated/ ios/Podfile* ios/Flutter/Debug.xcconfig ios/Flutter/Release.xcconfig ios/Runner.xcworkspace/contents.xcworkspacedata #android specific android/app/google-services.json android/key.properties # User-specific .idea/**/workspace.xml .idea/**/tasks.xml .idea/**/usage.statistics.xml .idea/**/dictionaries .idea/**/shelf # Generated files .idea/**/contentModel.xml # Sensitive or high-churn files .idea/**/dataSources/ .idea/**/dataSources.ids .idea/**/dataSources.local.xml .idea/**/sqlDataSources.xml .idea/**/dynamic.xml .idea/**/uiDesigner.xml .idea/**/dbnavigator.xml # Gradle .idea/**/gradle.xml .idea/**/libraries # Gradle and Maven with auto-import .idea/modules.xml .idea/*.iml .idea/modules *.iml # File-based project format *.iws # IntelliJ out/
-
tylerargo over 5 yearsHave you tried gitignore.io? There are usually some pretty sane defaults there: gitignore.io/api/android,flutter,androidstudio
-
Günter Zöchbauer over 5 yearsWhen you create a new Flutter project a
.gitignore
file is created already. What's wrong with that file? This file is not related to "enable Dart support". -
Serl over 5 yearsYour problem with "enabling Dart support" is because of the .idea in your .gitignore. .idea has codeStyle that makes Android Studio recognize your project as a dart project. Also check this link about making a .gitignore for flutter projects.
-
ch271828n about 4 yearsShall the
*.g.dart
be ignored?
-
-
ch271828n about 4 yearsShall the
*.g.dart
be ignored? -
DroidDev about 4 yearsShouldn't pubspec.lock also be ignored?
-
nstrelow about 4 yearsIt should be commited for applications: "For application packages, do commit pubspec.lock. This file is the recommended way for non-shared resources such as applications to manage their dependencies." dart.dev/guides/libraries/private-files
-
Zeeshan Ansari over 2 yearsFor library packages, don’t commit the pubspec.lock file. Regenerating the pubspec.lock file lets you test your package against the latest compatible versions of its dependencies. See dart.dev/guides/libraries/private-files#pubspeclock for more info.