pubspec.yaml deprecated layout - dart

Here is my pubspec.yaml.
name: oct
version: 0.1.0
description: >
Ojus Chemistry Toolkit (OCT) is an open-source toolkit for solving a
variety of cheminformatics problems. It is developed in Dart, mostly.
dependencies:
args:
sdk: args
When I run pub install, I receive a warning as follows.
Warning: Package "oct" is using a deprecated layout.
Reading pub's package layout details, I have not yet understood what is triggering the above warning. Request help! Thanks!

Most likely, you have some .dart files outside predefined directories:
lib
web
test
New SDK gives a helpful link if this problem occurs: http://www.dartlang.org/docs/pub-package-manager/package-layout.html

Lesiak is mostly right. You'll get this warning if pub finds any .dart files in your package's root directory. In the old layout, that was where you put your publicly importable files.
In the new layout, those should go under lib.

Related

error: Target of URI doesn't exist: 'package:test/test.dart'

Since the latest flutter update my tests are broken.
It looks like the Dart test framework isn't available anymore:
error: Target of URI doesn't exist: 'package:test/test.dart'.
If you've upgraded to a recent master, you'll find that flutter_test has removed its dependency on package:test. The package hasn't been removed or renamed, but you will need to specifically add it to you dev_dependencies in your pubspec now:
dev_dependencies:
test: ^1.5.1
The test_api package is just used to unify the versioning and reduce the depencies of flutter_test. It didn't replace package:test. There are also no breaking changes in any of these newer test versions.
The problem for me targeted URI doesn't exist was due to lib folder inside test package was not available at
file:///E:/APPS/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/dartz-0.9.2/lib/
so I downloaded it from GitHub and add it there manually and restarted the IDE. And It worked.

how to use local flutter package in another flutter application?

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!

Angular Dart Import Error With Tracing.dart

I am using Angular Dart for a project. In my pubspec.yaml I have
dependencies:
browser: any
angular: "^1.1.2+2"
shadow_dom: any
json_object: any
bootjack: any
crypto: any
xml: "^2.3.2"
transformers:
- angular
for my dependencies. When I run my program in Dartium I get the error
The requested built-in library is not available on Dartium.'package:angular/tracing.dart': error: line 9 pos 1: library handler failed
import "dart:developer";
^: package:angular/tracing.dart
I never reference or use anything out of the tracing.dart so I'm not sure why this is causing an error.
The tracing package is directly using dart:profiler, which was deprecated and now removed. You can now use dart:developer instead, both libraries are compatible.
I would suggest to fork the package, replace dart:profiler with dart:developer (no other changes are required) and send a pull request. I already forked and fixed the package some time ago here, but I think the original package is inactive so I didn't created an PR. You can use my fork by adding this to your pubspec.yaml:
dependency_overrides:
tracing:
git: https://github.com/Fox32/tracing.dart.git
dart:profiler was recently renamed to dart:developer. One of your dependencies probably use an analyzer version that doesn't fit to your Dart version.
See also https://github.com/dart-lang/pub/issues/1345

Dart Package Management via dart2js

I'm learning Dart and its dependency manager pub and am having a tough time seeing the "forest through the trees" here.
Say I want to use Polymer.dart in my project. So, in my project root, I create the following pubspec.yaml:
name: test_dart
description: A sample web application
dependencies:
browser: any
polymer: ">=0.9.0 <0.10.0"
I then run pub get, which goes to the pub repo and fetches the browser and polymer dependencies that I've specified. It then creates a packages directory in my project root, which now means I have a project that looks like:
MyDartProject/
pubspec.yaml
myapp.dart
packages/
browser/
...
...all the packages that ship with Polymer
Now I start coding my Dart web app (myapp.dart), which will references various Polymer and browser types/functions/etc. in its source code.
When I'm all done, I want to create a JavaScript file called myapp.js.
According to the dart2js docs, I need to run something like:
dart2js --out=myapp.js --package-root=??? myapp.dart
How do I include all the browser & polymer packages on the buildpath?
There is a "pub build" option now.
http://pub.dartlang.org/doc/pub-build.html
Use pub build when you’re ready to deploy your web app. When you run
pub build, it generates the assets for the current package and all of
its dependencies, putting them into a new directory named build.
$ cd ~/dart/helloworld
$ pub build
Building helloworld......
Built 5 files!
If the build directory already exists, pub build deletes it and then creates it again.
That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose "pub build"
EDIT: You should also see the links in zoechi's answer.
If you run dart2js from your MyDartProject directory you don't have to provide --package-root parameter.
An alternative way is running pub build. If you use Polymer you need to add a transformers section.
see also
How to deploy a Dart Polymer app to Javascript using dart2js
How do I pass multiple entry_points to polymer transformer in pubspec.yaml?

Dart pub is not downloading dependencies

I had moved my Dart Project to another folder, with the same folder structure, however, now, I'm receiving the following message:
Running pub install ...
Pub install failed, [1] Resolving dependencies...
Could not find package "dartflash 0.6.3" at http://pub.dartlang.org.
Here is my pubspec.yaml:
name: Chronium
description: A framework for doing Chrono like games.
dependencies:
dartflash: 0.6.3
And pubspec.lock:
{"packages":{"dartflash":{"version":"0.6.3","source":"hosted","description":"dartflash"}}}
And the file structure:
The website (http://pub.dartlang.org/) is accessible from the browser.
I'm on dart (Dart Editor version 0.2.9_r16323). Do someone knows what is happening?
According to Seth Ladd post, this should be fixed now :
If you were having troubles with pub.dartlang.org, we're happy to report that we've fixed the issue. Many apologies for the temporary downtime. Looks like it was an issue with the server pointing to the wrong data store. Thanks for all the reports, the pub is open again!

Resources