Following the sample on the Dartson documentation page,
import 'package:dartson/dartson.dart';
import 'package:some_dependency/some_class.dart';
import 'my_class.dart';
#Serializer(
entities: [
MyClass,
SomeClass,
],
)
final Dartson<Map<String, dynamic>> serializer = _serializer$dartson;
I'm getting undefined name _serializer$dartson.useCodec(json) and also wondering where _serializer is referenced from.
Yes, I have added the required dependencies to my pubspec.yaml.
dependencies:
dartson: ^1.0.0-alpha+2
dev_dependencies:
build_runner: ^0.10.0
The required dependency on build_runner indicates that a build step is needed. Depending on how Dartson define's its builders it may be enough to run pub run build_runner build (or for flutter, flutter packages pub run build_runner build.
You might want to file an issue on Dartson to make the build instructions more clear.
Related
Background:
This code is based on dated PM example written by Mattt years ago.
Goal: I'm trying to get importing to work, so I created a basic package; based on Mattt's working package. His example works flawlessly. Hence attempting to recreate from scratch.
Scenario:
I've created a basic package.
I've added a Dependency.
I've added an 'import <Dependency' in package source but I'm getting the following build failure:
Here's the actual code:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RicPackage",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "RicPackage",
targets: ["RicPackage"]),
],
dependencies: [
.package(name: "PlayingCard", url: "https://github.com/apple/example-package-playingcard.git", from: "3.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "RicPackage",
dependencies: ["PlayingCard"]),
.testTarget(
name: "RicPackageTests",
dependencies: ["RicPackage"]),
]
)
Question:
Why is this happening?
What am I missing?
Gremlins?
I played around with the package header to notice changes in syntax acceptance. Then I reverted to the latest and did a recompile.
This time it SUCCEEDED.
I did a Xcode restart just to be sure this is true.
I rebuild... again SUCCEEDED.
Note: be sure to be aware of the package header the says the version of the package. The package syntax (amongst other things) change/version.
I did a pub build this morning and all of a sudden, something that was compiling fine yesterday, with no changes today, is breaking.
Failed to precompile webdev:webdev:
../../../.pub-cache/hosted/pub.dartlang.org/dwds-3.1.3/lib/src/services/chrome_proxy_service.dart:40:7: Error: The non-abstract class 'ChromeProxyService' is missing implementations for these members:
- VmServiceInterface.getSupportedProtocols
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class ChromeProxyService implements VmServiceInterface {
^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/vm_service-4.1.0/lib/src/vm_service.dart:745:24: Context: 'VmServiceInterface.getSupportedProtocols' is defined here.
Future<ProtocolList> getSupportedProtocols();
^^^^^^^^^^^^^^^^^^^^^
Precompiling executables... (1.9s)
I've done a cache repair, another get to see if there are newer versions, I've done an upgrade just to be sure, but as soon as I hit activate webdev, I get the above error.
~/Code/dart-sdk-2.8.4/bin/pub cache repair
~/Code/dart-sdk-2.8.4/bin/pub get
~/Code/dart-sdk-2.8.4/bin/pub upgrade
~/Code/dart-sdk-2.8.4/bin/pub global activate webdev
~/Code/dart-sdk-2.8.4/bin/pub global run webdev build --verbose --output=web:build -- --delete-conflicting-outputs || exit
This is my pubspec.yaml, not much in there
name: blah
version: 0.0.0
description: Blah
environment:
sdk: ">=2.8.0 <3.0.0"
dev_dependencies:
build_runner: ^1.10.0
build_test: ^0.10.2
build_web_compilers: ^2.11.0
test: ^1.0.0
And I'm on Dart 2.8.4 (getting the same on other versions of Dart, so not sure if the Dart version has an effect)
Any ideas?
Seems like there's a temp workaround
pub global activate webdev 2.5.6
https://github.com/dart-lang/webdev/issues/1036
https://github.com/dart-lang/webdev/issues/1037
I'm a new developers with flutter, and i want to use "swagger" in my application. I add the dependencies of swagger in pubspec.yaml, but there's always an error.
pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
swagger: ^1.0.0
when i clicked Packages get, this is the following output:
Running "flutter packages get" in my_first_app...
Because my_first_app depends on swagger ^1.0.0 which doesn't match any versions, version solving failed.
pub get failed (1)
Process finished with exit code 1
How can i use swagger in my Flutter application?
You probably should use instead
open_api: ^2.0.1
swagger is deprecated and not compatible with Dart 2 and the requested version 1.0.0 doesn't exist at all.
From https://pub.dartlang.org/packages/swagger#-readme-tab-
I just started learning dart.
first I created an angular2-dart based project from https://angular.io/docs/dart/latest/quickstart.html and it worked properly.
now I want to add auth0-lock dart package from https://pub.dartlang.org/packages/auth0_lock, so I modified pubspec.yaml to the following:
name: go_dart_angular2_zingchart
description: Go Dart Angular2 with ZingChart Started Kit
version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: ^2.0.0-beta.18
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
auth0_lock: ^0.1.0
transformers:
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: client/web/main.dart
- dart_to_js_script_rewriter
and now when I execute pub get I get the following error:
Error on line 15, column 3 of ../../../.pub-cache/hosted/pub.dartlang.org/auth0_lock-0.1.0/pubspec.yaml: Error loading transformer "dart_to_js_script_rewriter": package "dart_to_js_script_rewriter" is not a dependency.
- dart_to_js_script_rewriter
^^^^^^^^^^^^^^^^^^^^^^^^^^
since I'm new to dart and not entirely sure what I'm doing.. I have no idea how to fix this :)
any ideas ?
thanks!
I get the same error when adding auth0_lock: ^0.1.0 to my dependencies and running pub get. The error message says that "dart_to_js_script_rewriter" is not a dependency in the pubspec.yaml of the auth0_lock package. It looks like it's added under dev_dependecies if you look here. Dev dependencies of any dependent packages are ignored. Pub only gets your package’s dev dependencies.
So I think this is a problem in their package.
So, what I did was I went to https://github.com/andresaraujo/auth0_lock.dart and cloned the package, added it into my own project root in a directory called auth0_lock. And then, in my pubspec.yaml i put:
auth0_lock:
path: auth0_lock
After that I can import it using
import 'package:auth0_lock/auth0_lock.dart';
I'm boldly stepping into the world of AngularDart, admittedly not knowing too much Dart itself yet. I'm creating a new application that does nothing (yet), except includes the latest 'angular' package.
I'm using Dart 1.2.0 and AngularDart 0.9.9.
Very simple pubspec:
name: myapp
dependencies:
angular: any
My app layout:
pubspec.yaml
pubspec.lock
\lib
\packages
\web
In web I have a simple myapp.dart:
import 'package:angular/angular.dart';
main() {
}
My build seems to work fine, but I get the following warning:
Dart: Build
[Warning from Dart2JS on myapp|web/myapp.dart]:
packages\angular\angular.dart:31:23: Hint: Can't find 'animate' in the library 'angular'.
Is 'animate' spelled right?
#MirrorsUsed(targets: const [
^^^^^^^^
My question is, what does this mean, and is this anything to be concerned about?
This was a bug in AngularDart 0.9.9 and is fixed in current versions.