skip to Main Content

I am starting a new project in flutter using vs code. I create a new project and get the general framework for the project.

I try to add a package
Here is my .yaml file
dependencies:
flutter:
sdk: flutter

cupertino_icons: ^1.0.3
flutter_icons: ^1.1.0
provider: ^6.0.5

When I run flutter pub get it gives me this:
[client_miner] flutter pub get
Resolving dependencies…
The current Dart SDK version is 3.0.5.

Because client_miner depends on flutter_icons >=0.0.2 which doesn’t support null safety, version solving failed.

The lower bound of "sdk: ‘>=2.0.0-dev.68.0 <3.0.0’" must be 2.12.0 or higher to enable null safety.
For details, see https://dart.dev/null-safety
exit code 1

First of all, I don’t know where I am getting flutter_icons >=0.0.2
Second, I get errors on the import package code:
import ‘package:flutter/material.dart’;
import ‘package:provider/provider.dart’;
This is the error:
Target of URI doesn’t exist: ‘package:provider/provider.dart’.
Try creating the file referenced by the URI, or try using a URI for a file that does exist.darturi_does_not_exist

How do I fix this? I have tried everything I have found but nothing works.
Thanks

2

Answers


  1. Use flutter pub add package_name command to add the package

    For Example:

    flutter pub add provider
    
    Login or Signup to reply.
  2. Since you use vs code you can simply enter the shortcut ctrl+shift+p and then in the search bar search for Dart: Add Dependency, after that you can search for your package and will do all the work for you from add package in pubspec.yaml and run command flutter pub add [package name]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search