how to import local package files in my main package? - flutter

I want to import the about.dart file in my main.dart file. But it is showing error while I'm copying its path. I tried many ways to import it, but all fails. Can anyone please help me in this?

if both the files are in the same folder you can import them using this line
import './dialpad.dart';
if you want to import the file from a folder at the same level of the file in which you want to import you can use this line
import '../widgets/some_file.dart';

To use your local package you have to define package and give a package path inside your pubspec.yaml for the package.
To add local package in pubspec.yaml:
sip_up-0.5.6:
path: ./sip_up-0.5.6

Related

Error: Could not resolve the package 'app' in 'package:app/app_controller.dart

In my last flutter project, I included files placed in my lib/ directory by using import 'package:app/file_name.dart'.
For example, my file located at lib/app_controller.dart was imported via:
import 'package:app/app_controller.dart'
I just started a new flutter project, and it is giving me the error:
Error: Could not resolve the package 'app' in 'package:app/app_controller.dart'
When I remove the portion package:app/, it builds fine. I find this very strange because my previous project is still building just fine without any changes. Does anyone know what's happening here?
What is allowing my old project to respect package:app/..., but not my new project?
package:app/ would work only for an application that is called app. What is the name of your new application? When you import items from your own project, it goes like this:
package:{{YOUR APPLICATION NAME}}/{{DIRECTORIES}}
What is the name in your pubspec.yaml file? It's usually on the very first line.
it is because a dart class can be imported in two ways(AFAIK),
local import from the root of current file where import is being used for example import '../folder/file.dart
with a package name which should begin from package for example import package:packagename/any_file_in_the_lib_folder.dart, a package will have a pubspec.yml which defines a package name which will be used to import the content of the lib folder of that package, in your case your first project is named app so it respected this import style but your second project isn't respecting it because its not named app but something else.

Importing library in Dart

I know that to import some library, which is located in some folder. Example hiearchy:
library1
folder1
library2
Then importing library2 would look like:
import 'folder1/library2';
But how can I import library1 from library2?
import '../library1';
or
import 'my_package:library1.dart';
when the file library1.dart is stored in my_package/lib/library1.dart and your package name in pubspec.yaml is my_package.
If the imported file is deeper down the path relative path import is fine, when it's higher up the absolute import path (package:...) should be preferred.
Only files stored somewhere in the the lib directory of your package can be imported using a package:... path.
You can try this
import '../library1.dart';

Determine location of jar file from import

If I have an import statement like:
import com.google.android.gms.maps.model.BitmapDescriptor;
is it possible to determine in Eclipse the jar file where this class is located?
try
ctrl-shift-t
type BitmapDescriptor
then show in Package Explorer

"The import org.apache.commons.fileupload cannot be resolved" does not go off despite adding lib

When I try to import
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
Eclipse shows an error,
The import org.apache.commons.fileupload cannot be resolved
I added these libraries but still this error does not go off.
commons-fileupload-1.3.jar
commons-fileupload-1.3-javadoc.jar
commons-fileupload-1.3-sources.jar
commons-fileupload-1.3-tests.jar
commons-fileupload-1.3-test-sources.jar
How should I correct this error?
I had to add these libraries in the build path after which it worked. Eclipse did not do it by itself.
You have to add these libraries at 2 places. To build path of the project and in /WEB-INF/lib folder

The import com.interwoven cannot be resolved

I am new to Teamsite and a not sure which jar file to use for resolving the issue that I get while trying to write a Java Datasource in Eclipse.
The list of imports I am using are:
import com.interwoven.datasource.MapDataSource;
import com.interwoven.datasource.core.DataSourceContext;
import com.interwoven.livesite.dom4j.Dom4jUtils;
import com.interwoven.serverutils100.InstalledLocations;
import com.interwoven.cssdk.filesys.CSVPath;
All these imports show the same error
The import com.interwoven cannot be resolved.
Can anyone please tell me which jar files should I add?