To solve the issue "depends on flutter from hosted, flutter_test from sdk is forbidden" in Flutter, you can try the following steps:
-
Check the version of
flutter_test
in yourpubspec.yaml
file.- Make sure you are using a compatible version of
flutter_test
with your Flutter SDK version.
- Make sure you are using a compatible version of
-
Ensure that your
pubspec.yaml
file includes the following lines:dependencies: flutter: sdk: flutter
-
Run
flutter pub get
to fetch and update the dependencies. -
If the issue persists, you can try deleting the
pubspec.lock
file and theflutter/.pub-cache
folder in your project's root directory. Then runflutter pub get
again to re-fetch the dependencies. -
If none of the above solutions work, it's possible that you have a conflicting package dependency. In this case, you can try the following steps:
- Run
flutter clean
to remove the build cache. - Update or remove any conflicting dependencies in your
pubspec.yaml
file. - Run
flutter pub get
to fetch the updated dependencies.
- Run
-
If the issue still persists, you may need to update your Flutter SDK. Ensure that you are using the latest stable version of Flutter and Flutter packages.
Hopefully, one of these steps will resolve the "depends on flutter from hosted, flutter_test from sdk is forbidden" issue in your Flutter project.