I am going to use Package Manager class in my code, but in android studio it is not recognizable class for it . I want to add dependency for it , but I do not know that how to search dependency related to this class on google so that I can easily find it and can add it to graddle.build file.
You can search for classnames in MavenCentral:
https://search.maven.org/
with c:yourClassName
Related
I am currently working on two Flutter apps that share about 90% of their functionality. Because of this, I have built most of the code as a library, and then have the two projects set up to import that library. I can then plug in two different CMS instances, and different Firebase services ... super-efficient.
The problem I have is that my library code has certain references that I would need to override in my projects to allow for bespoke menu items, theme settings etc.
A good example is a MenuItem enum that is used throughout my library code for navigation and routing etc. It builds the entire app structure off a list of these MenuItem types. I need to define a MenuItem enum for both of my projects, but the error I get is a conflict between the project and the library.
{MenuItem menuItem}
The argument type 'MenuItem (where MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_app/ar_trails_app/lib/utils/menu_items.dart)' can't be assigned to the parameter type 'MenuItem (where MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_Lib/weald_ar_trails/lib/utils/menu_items.dart)'.dartargument_type_not_assignable
menu_items.dart(7, 6): MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_app/ar_trails_app/lib/utils/menu_items.dart
menu_items.dart(8, 6): MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_Lib/weald_ar_trails/lib/utils/menu_items.dart
I know that there is an option to use dependency_overrides in Dart but this is for overriding the entire library I think: https://dart.dev/tools/pub/dependencies#dependency-overrides
How can I do this but for just one file? Or maybe two or three?
UPDATE:
To be clear on the use-case here: my file menu_items.dart is in the library package, and it is used throughout to build the navigation and drawer etc. But it is only used in the library. What I need to do is override that file in each project so that the reference the library uses is the project's local version and NOT the one that is being referenced in the library. I thought that if I used as a path reference to the file like ../../utils/menu_items, and mirrored that in my project, it might use the local project version. It doesn't.
native background in the javascript import module which is seen from the top of the code like this
import {some_fun} from "some_package";
but in dart how to find which module is imported from which package for e.g.
import "package/material.dart";
and many more
how to know which package contain which function or classes
To find that out. In Android Studio or VSCode just hover over the name of the package you are importing. In this case 'package/material.dart' and press ctrl+click.
It will redirect you to the code and you can see all the functions,classes and variables. Just remember anything starting with _(underscore) is private and can not be used in other classes. However if they have setters and getters defined for them then they can be accessed.
Looks like Flutter for Web and Flutter for Mobile have to exist as separate projects due to the imports.
Example:
import 'package:flutter_web/material.dart
vs
import 'package:flutter/material.dart';
Is there anyway to build one flutter project with one code base that works for both web and mobile (ios/android)? If not, is this coming?
If so, can you provide an example app?
Would like to just make one code base for the web and mobile and not have to maintain separate projects/code repos.
The OP's question is a bit old and is no longer applicable at the time of posting(7/21/2020). Flutter now has consolidated web into the main flutter package, which prevents us from running into issues with imports like this. flutter_web is no longer a separate package.
However, you may have been able to accomplish this even at the time you posted your question with conditional imports. This answer provides an excellent method of doing this. The following are the essentials of that post:
The core idea is as follows.
Create an abstract class to define the methods you will need to use in general.
Create implementations specific to web and android dependencies which extends this abstract class.
Create a stub which exposes a method to return the instance of this abstract implementation. This is only to keep the dart analysis tool happy.
In the abstract class import this stub file along with the conditional imports specific for mobile and web. Then in its factory constructor return the instance of the specific implementation. This will be handled automatically by conditional import if written correctly.
This method allows for you to do these imports based on platform and applies to all packages that may not support every possible flutter platform(e.g. dart:html, dart:js, dart:js_util, dart:io).
I know the name of the plugin to add into the ionic2. However, when come to import it by using ionic-native, I don't know how to write it.
For example, my plugin is: cordova-plugin-ms-adal, and I install
ionic plugin add cordova-plugin-ms-adal
But how to import this plugin? Is the following correct?
import {MSADAL} from 'ionic-native';
The quickest way is to dive straight into the source code of Ionic Native, you can find it GitHub. If we take the Geolocation plugin for example, you can see the following in the code:
export class Geolocation
This means that Geolocation is the name of the plugin you need to import.
However, in your case there is a simple explanation as to why it doesn't work. The cordova-plugin-ms-adal is simply not supported in Ionic Native. You could either create the implementation yourself and create a pull request to get it merged into the library or open an issue on GitHub.
i've added a plugin called Image tool plugin for image resizeing... but when i called an instance of it
def imageTool = new ImageTool()
it gives me compilation error cause it can't resolve ImageTool class . i've tried to put import
import org.grails.plugins.imagetools.ImageTool
as a suggestion from a site .. but it didn't work .. so what is the real path to the imageTool so i can import it?? any help please:)
You can't access a class from the default package in a class that's in a package, and ImageTool is in the default package. The easiest thing to do is move that class into a subfolder, e.g. src/imagetool and add "package imagetool" to the source. You'll need to do this for each developer.
The plugin has moved to http://github.com/ricardojmendez/grails-imagetools/ and this has been fixed in that code, but I don't know if they have done a new release.