Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change app name in pubspec.yaml cause error on imports

Tags:

flutter

dart

I have created a new flutter project in AS and for some reason the name in pubspec.yaml for my app is just app even when I named it something else when I created new app

name: app
description: My new application.

When I rename it to whatever I need then all my imports error out in my project.

Example:

import 'package:app/main.dart';

So how do you change the name in pubspec.yaml without crashing all imports

UPDATE After renaming name, AS doesn't show package option with the new name

enter image description here

like image 651
delmin Avatar asked Apr 29 '20 10:04

delmin


Video Answer


1 Answers

For example, if the default app name is

name: defaultappname
description: My new application.

and you want to change it to

name: app
description: My new application.

then you have to just do the search and replace operation:

Search and Replace Operation

like image 56
Krishnarajsinh Jadav Avatar answered Oct 05 '22 02:10

Krishnarajsinh Jadav