Home > Back-end >  Not a valid Dart package name - Flutter error
Not a valid Dart package name - Flutter error

Time:11-23

I want my app to be available for the web.

I run this command: flutter create .

I get this error: "Fredi" is not a valid Dart package name.

I know that there shouldn't be any capital letters. However, I do not know how to change the dart package name.

I have already used these packages successfully, but they seem to be changing other things, not the Dart Package Name.

change_app_package_name: ^1.1.0
rename: ^2.0.1

The only thing in my project with the name 'Fredi' is the root folder (original project name). However, I don't know how to change it (file explorer won't let me) and it will probably break things.

What step can I take?

Config Files

app/build.gradle -> applicationId "com.tomasward.fredi"

android manifest -> package="com.tomasward.fredi"

android manifest -> android:label="Fredi"> [I understand this is the name displayed to the user, I've tried changing it but it doesn't fix the error.]

CodePudding user response:

You can probably rename your package name with the help of some dependency that you can find on pub.dev by typing "rename" in the search bar.

All those dependencies will help you rename your package to a lowercase only package name, then you will be able to use the flutter create . command to create the web folder for your app.

CodePudding user response:

You can run flutter create --project-name "your_valid_package_name" InvalidPackageNameDirectory to create a Flutter project in a directory with a non-valid package name.

In an already existing project, you can change the package name by modifying the name property in the pubspec.yaml at the root of the project (see here for more details on the pubspec).

  • Related