I need to have a webview inside my context body, but not to cover the entire screen space as I have to display a listview below it.
I checked flutter_webview_plugin but it did not work
Getting the error :
That library is in a package that is not known. Maybe you forgot to mention it in your pubspec.yaml file?
dependencies:
flutter:
sdk: flutter
url_launcher: ^0.4.1
async_loader: "^0.1.1"
json_annotation: ^0.2.2
flutter_webview_plugin: "^0.1.5"
cupertino_icons: ^0.1.0
#url_launcher: ^3.0.0
dev_dependencies:
flutter_test:
sdk: flutter
json_serializable: ^0.4.0`
I have written below line in my dart file
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
If you add a new package to your dependencies, then do a hot reload, you get the following misleading message:
Performing hot reload...
Your application could not be compiled, because its dependencies could not be
established.
The following Dart file:
/usr/local/google/home/ianh/dev/release/startup_namer/lib/main.dart
...refers, in an import, to the following library:
package:package:flutter_webview_plugin/flutter_webview_plugin.dart
That library is in a package that is not known. Maybe you forgot to mention it in
your pubspec.yaml file?
Try again after fixing the above error(s).
Kill your application and start it again. This might solve your issue.
For more references please visit this git hub discussion
Go to the build directory, which will be located at the top level of your app along with lib, ios, android, etc.
If a flutter_webview_plugin folder is not there, then you need to run flutter pub get to download the package.
If the folder is there, then it has already been downloaded. If that is the case and your IDE is still telling you that it does not recognize the package, then try restarting your IDE.
Related
I want to use open cv and tensorflow for flutter agora sdk on ios, but I dont know how to import it. This is link repo https://github.com/AgoraIO/Flutter-SDK. Anyone can help me ?
Take a look at the example here: https://github.com/AgoraIO-Community/Agora-Flutter-Quickstart
To answer your question specifically, to import the SDK you need to add it to your pubspec.yml file in your Flutter project. This is where all the external packages are added.
dependencies:
flutter:
sdk: flutter
provider: 3.2.0
intl: ^0.15.8
agora_rtc_engine: 1.0.5
permission_handler: ^3.0.0
Depending on your development environment you will then have to prompt Flutter to get the dependencies by running flutter pub get or your IDE (Vscode, etc.) will detect the change and do it for you.
When I try and run my project in xcode, I am getting the following error:
'auto_orientation/AutoOrientationPlugin.h' file not found.
If I remove this plugin, it will then go to the next plugin and fail on the .h file for that plugin and so on for every single plugin.
Previously this issue only used to happen when I attempted to make an archive, but it would always run without issues. Now it will not even run.
There are many threads about this and I have run through these but have so far been unable to find any suggestion that is working.
Pubspec.yaml file, as requested:
name: app_name
description: My application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 6.0.0
environment:
sdk: ">=2.3.0-dev.0.5 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: 0.1.2
firebase_admob: 0.5.5
screen: 0.0.5
image_picker: 0.6.1
firebase_auth: 0.11.1+7
shared_preferences: 0.4.3
rflutter_alert: 1.0.2
url_launcher: 5.0.3
in_app_purchase: 0.2.0
firebase_dynamic_links: 0.4.0+4
app_review: 1.1.0+1
auto_orientation: 1.0.4
vibration: 1.2.1
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
assets:
- lib/images/
- lib/images/example1.png
- lib/images/example2.png
- lib/images/example3.png
uses-material-design: true
Screenshot for Cenk:
you definitely do not need to wipe out your whole ios/ folder.
1) flutter cleancause why not
2) rm ios/Podfile.lock
3) rm -rf ios/Pods
4) rm -rf ~/.pub-cache/hosted/pub.dartlang.org/ (or wherever you set this up to live)
5) flutter packages get
then run/build your app however you normally do it.
Sometimes I also get ios compilation error in my project working properly, I create a clean project with the same name, copy my codes there and it gets better.
I suggest you try if you can't find a solution.
I have had such issues before. The error was because I deleted a package dependency from my pubspec.yaml. As we know deleting a package as such will remove all the flutter files it downloaded form pub.dev but forgot to delete the permission and method I added into Info.plist and AppDelegate.swift manually as dependencies for that package.
When Xcode see this methods in the AppDelegate.switf, it searches for the required files but it can't find them because the package was deleted from pubspec.yaml.
So cross-check if the content of those 2 files matches the packages that require them.
Hope it helps.
Edit
Based on your pubspec.yaml, they are some keys that need to be added to your AndroidManifest and info.plist files respectively. I assume you haven't done that from your comment.
Locations
AndroidManifist is found in android/app/src/main/AndroidManifiest.xml
info.plist is found in iso/Runner/Info.plist
For the firebase_admob package you need to add the following to your AndroidManifest
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"/>
Where [ADMOD_APP_ID] is your App ID. Check firebase_admod to see how to initialize an app ID and how to initialize the plugin
Then you need to add the following to your info.plist
<key>GADApplicationIdentifier</key>
<string>[ADMOB_APP_ID]</string>
For screen 0.0.5 you need to add the following permission to your 'AndroidManifest`
<uses-permission android:name="android.permission.WAKE_LOCK" />
For image_picker: 0.6.1, you also need some permission added to the info.plist.
Add the following keys to your Info.plist file, located in /ios/Runner/Info.plist:
NSPhotoLibraryUsageDescription - describe why your app needs
permission for the photo library. This is called Privacy - Photo
Library Usage Description in the visual editor.
NSCameraUsageDescription - describe why your app needs access to the
camera. This is called Privacy - Camera Usage Description in the visual editor.
NSMicrophoneUsageDescription - describe why your app needs access to
the microphone if you intend to record videos. This is called Privacy
Microphone Usage Description in the visual editor.
Android No configuration required - the plugin should work out of the box
Not to be redundant, you need to browse you the package in you pubspec.yaml pub.dev page and follow the instruction to add all the dependencies for the packages to work.
I hope you project compiles now!
I guess you have some files missing for some reason.
I hope this steps maybe solve it:
backup your flutter project folder
delete "ios" folder from your your flutter project
run flutter create -i swift , this command will recreate new 'ios' folder
run your flutter project
In the end I found a fix for this in another forum:
Seems like by opening up the project by double clicking Runner.xcworkspace instead of Runner.xcodeproj xcode can finally figure out where everything is.
I tried this and it literally works. Now my app will run with a new error (because of course):
malloc: can't allocate region securely
But I will make a new question for that one.
I am getting an issue trying to compile an application in the flutter dev channel, I have tried with master channel too, but it doesn't work.
I got this issue:
Your application could not be compiled, because its dependencies could not be established.
The following Dart file:
C:\src\flutter\packages\flutter\lib\gestures.dart
...refers, in an import, to the following library:
C:\src\flutter\packages\flutter\lib\src\gestures\lsq_solverno.dart
Unfortunately, that library does not appear to exist on your file system.
I have this YAML file
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
google_sign_in: ^3.0.4
http: ^0.11.3+16
cached_network_image: ^0.4.1
share: ^0.5.2
graphql_flutter: ^0.9.4
camera: ^0.2.1
shared_preferences: ^0.4.3
redux: ^3.0.0
flutter_redux: ^0.5.2
material_design_icons_flutter: ^3.0.3392
vibrate: ^0.0.4
I also tried to run the flutter_gallery project from Flutter GitHub examples, it ran the first time, but now, it indicates the same issue that I am getting with my project.
The correct file name would be
C:\src\flutter\packages\flutter\lib\src\gestures\lsq_solver.dart
instead of
C:\src\flutter\packages\flutter\lib\src\gestures\lsq_solverno.dart
Your Flutter installation is corrupted. You probably accidentally modified a File in the Flutter install directory.
You can run the following command from the Flutter install directory to check
git status
To fix run in the Flutter install directory
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
How to use local flutter package in another flutter application?
I created a package using following command:
flutter create --template=package my_new_package
and then in my application source code => main.dart
import "package:my_new_package/my_new_package.dart" // can not find the package
Find this file in your flutter application => pubspec.yaml
Use local dependency
dependencies:
flutter:
sdk: flutter
my_new_package:
path: ./my_new_package
Note: The ./my_new_package above means that the my_new_package directory containing the pubspec.yaml for the package is a sub-directory of the app.
If you have the package as a directory at the same level as the app, in other words one level higher up in the directory tree, you can use ../my_new_package (note the double dot) or a full path to the package directory.
Path dependency: A Flutter app can depend on a plugin via a file system path: dependency. The path can be either relative or absolute. For example, to depend on a plugin plugin1 located in a directory next to the app, use the following syntax:
dependencies:
plugin1:
path: ../your_package/
For the full process:
Download the code for the plugin you want to use and place it at the "same" level as your flutter project directory
-- plugin-name
-- your flutter directory -- lib
-- android
-- ios etc etc
Add the plugin path to pubspec.yaml. *If you are unsure of the correct plugin name to use, look at the name: attribute in the plugin's pubspec.yaml file. The plugin directory must also be saved with the same name:
dependencies:
plugin-name:
path: ../plugin-name
Run Pub get and you can import just like any other plugin. Only difference is when you click on any of the plugin classes during development, it will point to the local file.
Hey I had same problem once I started using flutter.
I have implemented example of pdf_view plugin in my app for making changes for Shimmer effect instead of CircularProgressIndicator().
Some Knowledge
You can edit plugins which are get by flutter pub get but they might be replaced when you create app bundle by flutter.
Now your answer with sample plugin suppose take an example of advance_pdf_viewer
GitHub Link
Download zip file and extract it in pdf_viewer/
Make sure pdf_viewer/ has all files including lib, Android, iOS and all related files.
Copy your pdf_viewer folder in your project directory for example
my project is invoice_viewer so it's root directory have all folders such as lib, Android, iOS etc. copy it in this root directory along with lib, Android, iOS.
Now open your pubsec.yaml and write code as follows
dependencies:
flutter:
sdk: flutter
# advance_pdf_viewer: ^2.0.0
advance_pdf_viewer:
path: ./pdf_viewer
In comment I have replaced server version with local one and make changes in plugin's viewer.dart file to achieve desired changes.
Hope you and other got some information from this finding!
Hi I am trying to use the intl package in my flutter project. The packages get command runs successfully but when I import the package it shows error.
For the import in the my dart file I am using the following import
import 'package:intl/intl.dart';
I have also upgraded flutter from the terminal using the flutter upgrade command.
Here are some steps that I offten see as problems with dependencies in flutter.
The thing with pubspec.yaml is that you have to save it CRTL/CMD + S before pub get will work. Running pub get from IDE doesn't save the file automatically.
Try running flutter clean and then run flutter pub get.
Sometimes when you remove dependencies like plugins, .build folder doesnt get cleaned up properly so you have to do it manually.
You can try to repair pub cache by running flutter pub cache repair
Sometimes just restarting your IDE might solve the problem as well.
Faced the same issue, if you are importing
import "package:intl/intl_browser.dart";
then you will get that error, it seems like the dart SDK bundled with flutter does not have the required dependencies.
So use only
import 'package:intl/intl.dart';
and it should work just fine.
It needs to reload the flowing package using CTRL+S might not work sometimes. Need to restart IDE after saving pubspec.yaml file.
After the project cleaning you could have some error like this:
intl_browser.dart:13:8: Error: Not found: 'dart:html'
You can clean your cache, make all you want to refresh your flutter project:
- flutter clean
- rm -rf pubspec.lock .packages .flutter-plugins
- flutter pub pub cache repair
- flutter packages get
But you can't solve until you comment this line on your code :
findSystemLocale()
This line is in conflict with dart:html as you can see here below according with the current intl source:
library intl_browser;
import "dart:async";
import "dart:html";
import "intl.dart";
// TODO(alanknight): The need to do this by forcing the user to specially
// import a particular library is a horrible hack, only done because there
// seems to be no graceful way to do this at all. Either mirror access on
// dart2js or the ability to do spawnUri in the browser would be promising
// as ways to get rid of this requirement.
/// Find the system locale, accessed as window.navigator.language, and
/// set it as the default for internationalization operations in the
/// [Intl.systemLocale] variable.
Future<String> findSystemLocale() {
Intl.systemLocale = Intl.canonicalizedLocale(window.navigator.language);
return new Future.value(Intl.systemLocale);
}
It started working for me after I inserted one tab before 'intl'. Final set of code looks here...
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
intl: ^0.16.1
If you need to be able to use findSystemLocale() on both web and other platforms, you can use conditional import:
import 'package:intl/intl_standalone.dart' if (dart.library.html) 'package:intl/intl_browser.dart';
After that you can just write
Intl.defaultLocale = await findSystemLocale();
You will be able to build on any platform.
I had the same issue on Visual Studio Code with the latest stable version of flutter. none of the previous answers helped in my case.
Running pub cache repair, which was suggested by some of the answers, used up all my data since it started downloading all flutter packages regardless of whether I used them or not and didn't solve anything.
The solution that worked for me:
Instead of running flutter pub get package_name in the terminal, I had to add the package under the dependencies in "pubspec.yaml" file manually like so:
dependencies:
package_name: ^1.1.0
and save it.
After saving it the IDE would get the packages for me and everything worked.
I fixed it with a combination of things from this question and here.
Firstly, import intl_standalone in your main.dart, not intl_browser.
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:intl/intl_standalone.dart';
Then call the necessary setup function, like this:
void main() async {
Intl.defaultLocale = await findSystemLocale();
await initializeDateFormatting();
runApp(MyApp());
}
Make sure to add intl to your deps, like this:
dependencies:
flutter:
sdk: flutter
intl:
Then run the following commands in order from your project directory:
flutter clean
rm -rf pubspec.lock .packages .flutter-plugins
flutter pub cache repair
flutter pub get
With this I could get it to work when building to Android and iOS.
Bit late but this happened to me, check the name of your files isn't the same name as the package you want to import.
Worked for me by manually adding intl: ^0.18.0 in pubspec.yaml and saving it (Cmd+S).
dependencies:
flutter:
sdk: flutter
intl: ^0.18.0
Wherever required import as import 'package:intl/intl.dart';