Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter create --template=package creates platform folders #119844

Closed
thisisyusub opened this issue Feb 2, 2023 · 15 comments · Fixed by #125292
Closed

flutter create --template=package creates platform folders #119844

thisisyusub opened this issue Feb 2, 2023 · 15 comments · Fixed by #125292
Labels
found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project r: fixed Issue is closed as already fixed in a newer version tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@thisisyusub
Copy link

Steps to Reproduce

  1. Execute flutter create --template=package package_name

Expected results:
When we create package, I assume that it should only create dart files.

Actual results:
But unfortunately, it creates all platform folders - android, ios, macos and etc. I have tried to create package from Android studio, VS Code and even with flutter command.
Screenshot 2023-02-02 at 22 44 03

Screenshot 2023-02-02 at 22 44 51

Logs
// this is modular app (contains different flutter packages, web and android/ios app)
Analyzing Inside...                                                     
No issues found! (ran in 3.3s)
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65 darwin-arm64 (Rosetta),
    locale en-AZ)
    • Flutter version 3.7.0 on channel stable at
      /Users/kanza/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (10 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/kanza/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Users/kanza/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386
      /Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Users/kanza/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386
      /Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.15+0-b2043.56-8887301)

[!] Android Studio
    • Android Studio at /Users/kanza/Desktop/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Users/kanza/Library/Application
      Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/223.8617.56/IntelliJ IDEA
      CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0
@lucamenor
Copy link

Same problem here.

@guidezpl
Copy link
Member

guidezpl commented Feb 2, 2023

Related #116320

@Terranic
Copy link

Terranic commented Feb 2, 2023

They may be needed in case of platform dependent code (e.g. platform channels) -- don´t they? So a full template needs to setup all platform folders.

@guidezpl
Copy link
Member

guidezpl commented Feb 2, 2023

They may be needed in case of platform dependent code (e.g. platform channels) -- don´t they? So a full template needs to setup all platform folders.

That would be true for plugins, which are effectively packages + native code. Packages are generally pure Dart.

@maRci002
Copy link
Contributor

maRci002 commented Feb 2, 2023

Minimal dart package:
dart create --template=package my_package

You can add flutter sdk in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Feb 3, 2023
@darshankawar
Copy link
Member

Thanks for the report. Seeing same behavior as reported.

This document gives overview of some of the files generated using the said command, but nothing much on the folders created with it.

With this though for plugin to create, we specify platforms for which the plugin need to support and hence the respective folders are created.

stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.7.0, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.7.0 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (28 hours ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.8.0-3.0.pre.20, on macOS 12.2.1 21D62 darwin-x64,
    locale en-GB)
    • Flutter version 3.8.0-3.0.pre.20 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision bc45b18589 (2 hours ago), 2023-02-02 21:37:03 -0500
    • Engine revision 2696fff871
    • Dart version 3.0.0 (build 3.0.0-196.0.dev)
    • DevTools version 2.21.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added tool Affects the "flutter" command-line tool. See also t: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 and removed in triage Presently being triaged by the triage team labels Feb 3, 2023
@thisisyusub
Copy link
Author

Thanks for comments.
@darshankawar so I understood it is okay for packages to generate different platform packages, right?

@thisisyusub
Copy link
Author

Minimal dart package: dart create --template=package my_package

You can add flutter sdk in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

Yes this is true but this package can't depend on Flutter related things (for example, creating any feature ui with material and cupertino components in this package and so on), but in the normal case we would create package that can use Flutter related codes too.

@christopherfujino christopherfujino added the P3 Issues that are less important to the Flutter project label Feb 7, 2023
@christopherfujino
Copy link
Member

Although I didn't know about this template, it seems a valid use case where you want to author a package that calls dart:ui.

@eximius313
Copy link

if this platform specific packages are supposed to be generated, please allow at least to configure them via --platforms, because not everybody needs every platform

@Rexios80
Copy link
Contributor

The package template has always been to create reusable dart-only flutter code. Adding platform-specific files would make the project a plugin instead. This template only recently started generating platform folders. The files generated seem to be files that would be ignored anyways even if they were supposed to be there. Except they aren't ignored because this template isn't supposed to be generating them.

Screenshot 2023-03-15 at 6 26 57 PM

@abdulrojakdev
Copy link

Same problem here.

auto-submit bot pushed a commit that referenced this issue Apr 29, 2023
`package` template should not create platform folders. This happen cause by default all platforms are supported and tools didn't distinguish between package and other template, which makes all platforms are true for below code,
https://github.com/flutter/flutter/blob/d186792c00f61149916f685e2975300342f64749/packages/flutter_tools/lib/src/project.dart#L374-L380

fixes: #119844 which make #116320 makes invalid. As for why tools created deprecated `Android Embedding`, `appManifestFile` does not exist for `package` template, which make below code to trigger,
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/project.dart#L768-L770

This does not happen with `module` and `plugin` as it have specific condition check for them. I try to reproduce it with `app` template but didn't succeed
@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label May 2, 2023
@abdulrojakdev
Copy link

why is this issue not resolved in Flutter version 3.10.0 ?

@christopherfujino
Copy link
Member

christopherfujino commented May 12, 2023

why is this issue not resolved in Flutter version 3.10.0 ?

because it was merged after Flutter 3.10 branched. See https://github.com/flutter/flutter/wiki/Where%27s-my-commit%3F for more context.

rk0cc added a commit to rk0cc/intl_script_recognizer that referenced this issue May 13, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project r: fixed Issue is closed as already fixed in a newer version tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants