Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dart null safety block me even without dependencies

Intro

I have new project.

I have pub.spec generated by Android studio official flutter plugin.

Nothing manually added / changed in config.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Problem

When I run pub get I receive error:

The current Dart SDK version is 3.1.3.

Because my_app depends on dependencies any which doesn't support null safety, version solving failed.

The lower bound of "sdk: '>=2.0.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.

my pub.spec

name: my_app
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0

environment:
  sdk: '>=3.1.3 <4.0.0'

dependencies:
  dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true
  assets:
     - assets/images/icons/

Question

1 How to solve it?

2 What does it means depends on dependencies any ?

>Solution :

Your pubspec.yaml seems messed up by something. You have dependencies twice so it does actually attempt install a package named dependencies which in fact does exist but are very old and deprecated (and does not support null-safety). Try use this instead:

dependencies:
  flutter:
    sdk: flutter
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading