Flutter: Problem with importing a dart file to flutter project - flutter

I want add a dart file in my flutter project. The dart file has some basic code. I wrote the import statement import dartfilename.dart in my main project file. But there is a red line under the import darfilename.dart. Could someone please help me? New updates are sometimes very a big problem.

import 'package:darfilename.dart';

If you start typing the import statement, your IDE (I'm sure Android Studio does this, but so should VSCode) will suggest files to import. You'll need to point to the correct path of the file. Say your file is in the folder basic_code, you'd do
import 'basic_code/dart_file.dart';
Or if it's a folder up from main, it'd be
import '../dart_file.dart';
If it's in the same folder, you should be able to simply call it directly
import 'dart_file.dart';
So it depends on your file structure. Take a look at this documentation page for more info: https://dart.dev/guides/language/language-tour#using-libraries

Related

Why does the flutter folder have an error

So i have this problem where in the flutter folder having some error but it does not affect on my project. its just that it slows down the vscode and might cause future error in my future projects.
Your main function should be in the file main.dart under the top level lib directory.
An error doesn't affect your application because it seems like this file is not used in your main project.
import 'package:test/test.dart'; doesn't exist which means you might be not added in pubsec.yml file or didn't sync it properly(put get).
https://pub.dev/packages/test go here to check how to implement and use it or if you don't need it for now just remove it or comment it.

Failed to import package with error: Couldn't decompress package

I've been trying to import the asset called Winter Forest Envoriment and everytime I click import it gives me the error "Failed to import package with error: Couldn't decompress package
UnityEngine.GUIUtility:,ProcessEvent(Int32, IntPtr, Boolean&)"
I've stumpled across some other threads were they imported outside the unity package manager, and not directly from the package manager. Other assets works like a charm except this one, and since there aren't a remove button in the package manager anymore I can't delete and try again.
Any help is appreciated :)
Try deleting and re-downloading. You'll likely find it under:
%AppData%\Roaming\Unity\Asset Store-5.x
I've encountered this issue before when I didn't have enough disk space on my computer for Unity to decompress the package. So, if you haven't done so yet, check that you have enough storage.
make sure you have the required space and the project folder location in a writable directory
use winrar to open the unitypackage, it will display a file within it, extract that file and import it as custom package, note: when you try to import the extracted file change file type from unity package to all in the import select window
your unity 3d is in play mode that's why it not import first stop your game play.
Check the space on the drive:
%AppData%\Roaming\Unity\Asset Store-5.x
which is under your main user directory on the system drive
NOT necessarily the same drive where Unity is installed.
Once there is enough space and write permission on this drive, go in
and Delete the folder in there containing the Asset you were trying to
install. (eg Yughes Free Ground Materials)
Go back to the package manager and refresh the list of assets, which should make the Download button reappear.
Redownload the package and import successfully.
This step by step is basically a summary of the correct information from the above answers.

How do I use pyinstaller to package a large multi-folder project?

Here is an example project folder structure similar to my actual project.
-repo_folder
--app_folder
---GUI_folder
----GUI1.py
----GUI2.py
---calculations_folder
----calculations1.py
----calculations2.py
---main.py
--cli.py
cli.py points to main.py. Main.py only import GUI1.py. And from there GUI2.py is imported and so on.
Basically, is there an easy way to make sure that all the importing done in each file is included? I have not been able to succesfully export a project with this kind of folder setup succesfully using pyinstaller. I keep getting "Failed to execute script cli" or "No module named GUI".
Could someone make an example of how the code would be import for a project structured like the above?

How can I import custom modules from a Github repository in Google Colab?

I understand how to run a single notebook in Colab. However, I am not sure how to use all files from a repository, i.e to be able to import functions inside Colab notebook?
Thank you.
Let's say we want to run the ipynb file, named as "1-fully-connected-binarized-mnist" residing in the repo "qnn-inference-examples".
https://github.com/maltanar/qnn-inference-examples
The notebook of interest uses customly created QNN library and functions inside that repo. Yes we need to import that function. To do this, we should first upload the repo folder to Google Colab, then correct/modify library and file paths.
0) Open the ipynb file "1-fully-connected-binarized-mnist" on your Colab. You can rename it if you like.
Try to run it, but will probably get some errors (as I did). So let's fix these issues
1) Insert a new code cell at the top of the notebook. And clone the repo on your Colab:
!git clone https://github.com/maltanar/qnn-inference-examples.git
now the new folder "qnn-inference-examples" created under your "content" folder. you should see something like this on the left side. And remember the path "/content/qnn-inference-examples"
2) Now add the second new cell on top:
import sys
sys.path.insert(0,'/content/qnn-inference-examples')
This will fix the issue about not able to find the library location, when trying import the QNN libraries.
3) Manually fix the file links on the existing code, according to the new path. Because the library and files now exist under the folder "/content/qnn-inference-examples":
for example replace:
img = Image.open("7.png")
with
img = Image.open("/content/qnn-inference-examples/7.png")
These steps should do the work
Please note that: This is not my own solution, mix of 2 or 3 solutions. Credit goes to Hüseyin Elçi, KDnuggets and Alexandr Haymin
https://medium.com/analytics-vidhya/importing-your-own-python-module-or-python-file-into-colab-3e365f0a35ec
https://www.kdnuggets.com/2018/02/google-colab-free-gpu-tutorial-tensorflow-keras-pytorch.html/2
Please see the example below:
!git clone https://www.github.com/matterport/Mask_RCNN.git
from google.colab import files
files.os.chdir('Mask_RCNN')
# To find local version of the library
sys.path.append(os.path.join(ROOT_DIR, 'Mask_RCNN'))
# here is your import
from mrcnn.config import Config

Go, Golang : external package import with GOROOT

Go, Golang : does not make sense that I have to have files before import
I am trying to go to next step but keep getting errors
I have the package that I want to import ready.
All I need to do is to import the external package from github and be able to use it on any code.
So this is what I did.
mkdir $HOME/go
export GOPATH=$HOME/go
go get github.com/user/project
This runs successfully. I downloaded it onto here with source code files from github
/Users/user/go/src/github.com/user/project/project.go
So to use this package that I just import I do
go run /Users/user/Desktop/code.go
But I am getting the following errors
MacBook-Air:~ user$ go run /Users/user/Desktop/code.go
Desktop/code.go:32:8: cannot find package "project" in any of:
/usr/local/go/src/pkg/project (from $GOROOT)
/Users/user/go/src/project (from $GOPATH)
What should I do? AM I missing something? Thanks in advance and please help me. I wrote a lot of code but being very frustrated not being able to distribute it because of this.
The error message says at line 32 in your code.go it can't find package "goling".
Assuming that is a local package you want to use, you need to make sure it is in your GOPATH.
If you set GOPATH then you should develop your code within it, so moving the "goling" directory into /Users/user/go/src is the right thing to do.
Alternatively "goling" could be a typo, so check the imports in code.go. If you want to import an project from github the import should say
import "github.com/user/project"
And you then use the parts of project with a prefix of project.
If that doesn't help you get it working, then post the imports section of code.go.
It looks like you've got the external package in the same folder as your main package which uses it. In go, all packages must be in separate directories. It looks like the github project itself is actually doing that. If you separate the packages into different directories it should work properly.