I am getting the following error on running flutter create my_appName: "my_appName" is not a valid Dart package name

Viewed 4487

enter image description here

I have tried upgrading flutter to the latest version. I am still getting the same error.

3 Answers

Package names should be all lowercase, with underscores to separate words, just_like_this. Use only basic Latin letters and Arabic digits: [a-z0-9_]. Also, make sure the name is a valid Dart identifier -- that it doesn't start with digits and isn't a reserved word.

see this - https://dart-lang.github.io/linter/lints/package_names.html

I was getting the exact same error.
After Renaming my working directory as per the naming convention attached by the Flutter team here which @Rushikesh just mentioned. It worked for me..
The reason is that the Flutter SDK uses directory/folder names as packages names and I was using a hyphen in my directory name. In your case mybmicalculator or my_bmi_calculator might work instead of myBmiCalculator .
Give it a try, that might be one of the errors.

I think your app's folder name has some capital letters, any digit at the start, or something like that. I faced this as my app's folder name had capital letters and when I used all small letters the problem was solved.

Related