Skip to content

flutter create uses directory name rather than package name to check name validity #53106

Closed

Description

@yjbanov

I tried to add web support to an existing mobile app. The name of the app in the pubspec.yaml is a valid package name. However, the directory that contains the package (which is derived from a git repository name) contains a dash "-" in the name. Running flutter create . in the package results in:

"xxxxx-xxxxxx" is not a valid Dart package name.

See https://dart.dev/tools/pub/pubspec#name for more information.

/cc @jonahwilliams

Activity

  1. added
    c: crashStack traces logged to the console
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Mar 23, 2020
  2. Zazo032 commented on Mar 23, 2020

    @Zazo032
    Contributor

    This same issue happened to us with a directory like com.xxxxxxxxxx.app, the workaround I did was to rename the folder and delete the wrongly generated files in android/ and ios/.

  3. jmagman commented on Mar 24, 2020

    @jmagman
    Member

    final String projectName = stringArg('project-name') ?? globals.fs.path.basename(projectDirPath);

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 24, 2020
  5. jonahwilliams commented on Mar 24, 2020

    @jonahwilliams
    Contributor

    You need to pass --project-name like @jmagman says above. Is this not working?

  6. yjbanov commented on Mar 24, 2020

    @yjbanov
    ContributorAuthor

    It probably does, but it doesn't make sense to have to pass this option when adding web support to an existing project. The project name is right there in the pubspec.yaml file.

  7. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 24, 2020
  8. yjbanov commented on Mar 24, 2020

    @yjbanov
    ContributorAuthor

    The other issue is that the error message is misleading. While it technically correctly states that "xxxxx-xxxxxx" is not a valid Dart package name., it implies that "xxxxx-xxxxxx" is being used as a package name, which is wrong.

  9. added
    c: new featureNothing broken; request for a new capability
    and removed
    c: crashStack traces logged to the console
    on May 30, 2020
  10. AseemWangoo commented on Jun 29, 2020

    @AseemWangoo

    Can you try this

    flutter create --project-name=xyz .

  11. added
    P2Important issues not at the top of the work list
    on Aug 18, 2020
  12. esDotDev commented on Sep 1, 2020

    @esDotDev

    Can we just have the run command just use the name as defined in .yaml or the module name?

    I'm guessing a grand total of 0 people want to use the folder name as the name for their actual project. Especially as names change, and folders tend not to.

  13. vineetjk commented on Nov 8, 2020

    @vineetjk

    just now i faced the same issue after cloning a repository from github and i found out that after cloning the repository the file name was having capital letters that is not supported by dart, so i just renamed the folder and tried the command flutter create . and it worked.. i hope this helps to people facing the same problem as mine.

  14. 19 remaining items

  15. thealidev commented on Nov 15, 2022

    @thealidev

    Easyest Way
    Simply Create New Blank Project And Move "web" Folder To Your Project

  16. ninetynin commented on Nov 15, 2022

    @ninetynin

    Easyest Way Simply Create New Blank Project And Move "web" Folder To Your Project

    That aint the easiest and best way

    hmm maybe it might be but why when there's a command to do this..
    I just feel like this is a solution that solves for temp puproses but not in a long run

  17. martinezinsua commented on Jan 9, 2023

    @martinezinsua

    just now i faced the same issue after cloning a repository from github and i found out that after cloning the repository the file name was having capital letters that is not supported by dart, so i just renamed the folder and tried the command flutter create . and it worked.. i hope this helps to people facing the same problem as mine.

    Thank you very much!!

  18. YawarOsman commented on Apr 29, 2023

    @YawarOsman

    IDK if you fixed it or not, but i had the exact the issue so i just rename my project name from "admin-panel" to "adminpanel" without any space and then the flutter create . worked perfectly

  19. sagarshende23 commented on May 26, 2023

    @sagarshende23

    IDK if you fixed it or not, but i had the exact the issue so i just rename my project name from "admin-panel" to "adminpanel" without any space and then the flutter create . worked perfectly

    Thank you So Much Bro... Working :-)

  20. navaronbracke commented on Jun 21, 2024

    @navaronbracke
    Contributor

    I just ran into this as well, seems like this bug had been in the tool for a while...

    I agree with the points above, we should be using the pubspec name as fallback instead.
    I'll take a look at figuring out a test and fix for the underlying tool bug.

  21. github-actions commented on Jul 17, 2024

    @github-actions

    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.

  22. locked as resolved and limited conversation to collaborators on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions