tapizquent
tapizquent

Reputation: 909

Flutter clean command causes null safety errors

Ever since null-safety was introduced to Flutter, when I do flutter clean, the whole project switches to null-safety.

I can not update my whole project to null-safety quite yet as many packages I use have not migrated.

How can I do a flutter clean without getting thousands of errors telling me that non-nullable item must be initialized first...

I am currently on Flutter 1.24.0-10.2-pre, channel beta.

pubspec.yaml includes the following

environment:
  sdk: ">=2.2.2 <3.0.0"

Upvotes: 4

Views: 6610

Answers (6)

Adebayo Seun
Adebayo Seun

Reputation: 21

Using VS code editor:

  1. Go to terminal
  2. Execute flutter pub get

The above fixed similar issue I got

Upvotes: 2

Ransford Owusu
Ransford Owusu

Reputation: 114

If you get an error after running "flutter clean", do the following to solve the problem;

  1. Go to your terminal
  2. Run this command: "flutter pub get"

After this you'll see "Running 'flutter pub get' in 'xxx'(where xxx stands for the name of your project)

When this is complete, all will be reset back to normal

Upvotes: 0

Collins Stark
Collins Stark

Reputation: 11

Sometimes you have to run this command:

dart pub upgrade

or

dart pub update

Upvotes: 0

AMMAR ELHAMDO
AMMAR ELHAMDO

Reputation: 529

I have the same problem, For me

  1. Go To 'Terminal'
  2. Type 'flutter pub get'

That is!! I am using VS code.

Upvotes: 0

koncode
koncode

Reputation: 51

I have the same issue. For me running flutter pub get worked. But I still don't know why this error happens

Upvotes: 5

Simon Warrington
Simon Warrington

Reputation: 91

I get exactly the same issue. I haven't found a fix yet but if you open the pub spec.yaml file and save it without making changes it solves the issue until you next run flutter clean.

Upvotes: 9

Related Questions