Why is flutter not detecting locally made packages? - flutter

I have been assisting with building an app with Flutter.
My senior shared the repo with me, however when I cloned it, all of the import packages had a 'uri not found' error.
I ran flutter pub get, and all of the external packages work. However the locally made packages, such as 'package:projectname/utils/utils.dart' still have an error.
How can I fix this? Preferably the fix is in my enviroment. I do not want to change any of the code since it works for him. TIA.

pubspec.yaml
dependencies:
flutter:
sdk: flutter
stackoverflow_pkg:
path: C:\Users\xxxxx\flutter_projects\stackoverflow\stackoverflow_pkg
code:
import 'package:stackoverflow_pkg/stackoverflow_pkg.dart';

Related

By updating Flutter 3.8.0 Error in flutter_date_time_picker

By updating Flutter 3.8.0
I am getting the following error in flutter_date_time_picker.
I would like to know if anyone knows a solution to this problem.
../../../../.pub-cache/git/flutter_datetime_picker-eb66486c47d50bf550950c196486121ffcea8885/lib/flutter_datetime_picker.dart:7:1: Error:
'DatePickerTheme' is imported from both 'package:flutter/src/material/date_picker_theme.dart' and'package:flutter_datetime_picker/src/datetime_picker_theme.dart'.
pubspeck.yaml
flutter_datetime_picker:
git:
url: https://github.com/Realank/flutter_datetime_picker.git
If anyone knows of a solution, I would love to hear about it.
I believe this is probably due to the flutter update, as I was able to build normally until yesterday!
If anyone knows of a solution, I would love to hear about it.
You can try the following steps:
Remove the flutter_datetime_picker package from your pubspec.yaml file.
Run flutter clean in your terminal to remove any cached files.
Re-install the flutter_datetime_picker package.
first try to flutter clean and then pub get and reinstall the package you want. if again you had this error try this:
To resolve it; in the class where you have both imports, assign an alias to one of the packages using the as keyword.
import 'package:flutter/src/material/date_picker_theme.dart' as dp
dp.EveryMethodYouWant(); //call the class using the alias
if you had any question i'm here.
happy coding.
By mistakenly,you have imported the wrong package because as per the package documentation, there is no such line mentioned.
Import the package mentioned below and try pub get.
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
everything vill works fine.

Flutter assests_audio_player import doesn't work

My flutter has suddenly started giving me this error on assets_audio_player : "Undefined class 'AssetsAudioPlayer'.". The import for the player: import 'package:assets_audio_player/assets_audio_player.dart'; is also greyed out. I've tried upgrading the flutter & restarting the device but the issue is still there. Any clue what might've gone wrong? Thank you!
Before importing the package in your code, did you properly add its dependency in your "pubspec.yaml" file and then run the flutter pub get command?
I am guessing you're using this package.
Be sure to add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get).
dependencies:
assets_audio_player: ^3.0.4+1

flutter has a problem with redux dependencies

i have a problem to run my flutter app, it seems flutter doesn't recognize it. i tried to connect to internet while running the project but the problem remains the same, here is the error message:
and here is the code where i inserted the dependency :
dependencies:
redux: ^4.0.0
flutter_redux: ^0.6.0
Your package name is likely also redux according to this Github issue. You'll have to change your package name to something other than redux and you should be able to flutter pub get.
this error was caused by the fact that i named my app REDUX, i changed it and it works now.

Flutter autocomplete not working in VSCode for packages

I moved my whole flutter project to a new folder, everything runs fine. The autocomplete works on the build in files from flutter, like Container, Column, but when I try using a package, like provider, I need to go on the pub.dev page and copy the import, import it manually, then I have to write "Provider.of(context)" manually. In the old project, I used to write Provider, press TAB, and everything would be auto imported and the VSCode would auto complete everything related to provider, not just bult in files. Whan should I do?
You must make sure that your dependencies for plugins are mentioned under dependencies: section, not under dev_dependencies: section like following:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.13.7
firebase_auth: ^0.16.1
fluttertoast: ^7.0.2
I was getting the same issue and fixed it by changing the flutter channel.
The problem seems to be with the dart that ships with the flutter code.
If you are still facing this issue. Then try to change your channel
flutter channel ...
And then try
flutter upgrade
This will pull the dart version again and hopefully fix the import issue.
Try to restart VS Code, worked for me.

Flutter web cannot use packages from mobile project

A few months ago I made an android application using flutter. The application requires various dependencies such as intl, cached network image, stopper, carousel_slider, etc.
Then right now I want to convert the project to flutter_web. Here are the steps that I did:
clone github web flutter
I run the command "flutter packages pub global activate webdev"
Then I edited pubspec.yaml and I adjusted it to pubspec.yaml in the previous project (android project)
Here is the contents of pubspec.yaml on the web flutter project:
name: flutter_web.examples.hello_world
environment:
  # You must be using Flutter> = 1.5.0 or Dart> = 2.3.0
  sdk: '> = 2.3.0-dev.0.1 <3.0.0'
dependencies:
  flutter_web: any
  flutter_web_ui: any
  stopper: ^ 1.0.1
dev_dependencies:
  build_runner: ^ 1.4.0
  build_web_compilers: ^ 2.0.0
dependency_overrides:
  flutter_web:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages / flutter_web
  flutter_web_ui:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages / flutter_web_ui
  provider:
    git:
      url: https://github.com/kevmoo/provider
      ref: flutter_web
When I run 'pub dev', an error occurs while resolving the package stopper. Then I tried to open github from the package stopper (https://github.com/aryzhov/flutter-stopper), after that I checked the files in the lib folder. There I found a file called stopper.dart. It turns out that in the file, still using
 import 'package: flutter / material.dart';
So that makes my pubspec error. Because the code should be replaced with
import 'package: flutter_web / material.dart';
Therefore, I tried to outsmart the problem by removing the dependency stopper on pubspec.yaml, then I created a stopper.dart file manually, then I saved it in the lib/mypackages folder. After that, I import stopper.dart from the lib/mypackages folder (it's no longer through the package).
The package stopper is just one of the packages that I use on my Android project. Actually there are many other packages that have the same problem as the package stopper. The point is I have to create the package files manually, then I change "package: flutter / ..." to "package: flutter_web /" manually, then I can import them.
What I want to ask, is there a more elegant and simple way?
Hi the instruction you are following is from an old repository here. As you can see this is discontinued. You can find the informaiton in the REadme.
Instead you should follow the instructions in this page. Read it once carefully and I would suggest to keep a backup of your main project and work on a copy.
First you will have to enable the flutter-web using flutter config --enable-web.
Then you will have to run flutter create .