一旦我创建了BrowserClient的实例,我就会在浏览器控制台中看到一个堆栈跟踪,然后应用程序就会死掉。
import 'package:http/browser_client.dart';
...
var client = new BrowserClient()
..withCredentials = true;
Stacktrace和http / src / utils.dart中的相关代码:
'包:http / src / utils.dart':错误:第89行pos 1:意外令牌 '流' Stream onDone(Stream stream,void onDone())=> ^: 包:HTTP / SRC / utils.dart
/// Calls [onDone] once [stream] (a single-subscription [Stream]) is finished.
/// The return value, also a single-subscription [Stream] should be used in
/// place of [stream] after calling this method.
Stream/*<T>*/ onDone/*<T>*/(Stream/*<T>*/ stream, void onDone()) =>
stream.transform(new StreamTransformer.fromHandlers(handleDone: (sink) {
sink.close();
onDone();
}));
如果我只导入它,异常看起来不同 - stacktrace和async / src / byte_collector.dart中的相关代码
&#39;包:async / src / byte_collector.dart&#39;:错误:第42行pos 1: 意外的令牌&#39; T&#39; T _collectBytes(^: 包:异步/ SRC / byte_collector.dart
T _collectBytes<T>(
Stream<List<int>> source,
T result(StreamSubscription<List<int>> subscription,
Future<Uint8List> result)) {
关于最新版本的浏览器和http依赖项
browser: "^0.10.0+2"
http: "^0.11.3+13"
我需要注意的BrowserClient
有什么变化吗?这段代码过去两年来一直很好用。
我已尝试使用Dart版本1.22.1
和1.23.0
,我确保Dartium是最新的并且符合Dart版本。 pub build
也没有显示任何错误。
实际上,仅仅导入import 'package:http/browser_client.dart';
会导致堆栈跟踪无论是否被使用。
如果有帮助,请填写pubspec.yaml
:
...
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: "^2.2.0"
bootjack: "0.6.7+2"
browser: "^0.10.0+2"
event_bus: "^0.4.1"
less_dart: any
http: "^0.11.3+13"
dart_to_js_script_rewriter: "^1.0.2"
transformers:
- angular2:
platform_directives:
- package:angular2/common.dart#COMMON_DIRECTIVES
platform_pipes:
- package:angular2/common.dart#COMMON_PIPES
entry_points: web/main.dart
- dart_to_js_script_rewriter
- $dart2js:
commandLineOptions: [--enable-experimental-mirrors]
- less_dart:
entry_points: [web/css/main.less]
build_mode: dart
降级http
也无济于事。
我已完成pub cache repair
,我已删除pubspec.lock
文件并重新运行pub get
,只要我导入/使用BrowserClient
,错误就会一直存在}
==================
测试应用程序以重现问题:
==================
lib/components/bug-fix.dart
import 'package:angular2/angular2.dart';
import 'package:angular2/core.dart' show AfterContentInit, Component;
import 'package:angular2/router.dart'
show ROUTER_DIRECTIVES, Route, RouteConfig;
// uncomment this line to make it crash
// import 'package:http/browser_client.dart';
@Component(
selector: 'bug-fix',
template: 'test',
providers: const [],
directives: const [ROUTER_DIRECTIVES]
)
@RouteConfig(const [
])
class AppComponent {
}
web/index.html
<!DOCTYPE html>
<html>
<head>
<!--<base href="/">-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="developed-by" content="jVaaS (Pty) Ltd">
<title>BugFix APP</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!--<link rel="stylesheet" href="css/main.css?4">-->
<!--<script src="cordova.js"></script>-->
</head>
<body >
<bug-fix class="noselect">
</bug-fix>
<script async src="main.dart" type="application/dart"></script>
<script async src="packages/browser/dart.js"></script>
</body>
</html>
web/main.dart
import 'package:angular2/angular2.dart' show provide;
import 'package:angular2/platform/browser.dart';
import 'package:angular2/router.dart' show ROUTER_PROVIDERS;
import 'package:angular2/src/platform/browser/location/hash_location_strategy.dart';
import 'package:angular2/src/platform/browser/location/location_strategy.dart';
import 'package:bugfix/components/bug-fix.dart';
void main() {
// bootstrap angular2
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(APP_BASE_HREF, useValue: '/'),
provide(LocationStrategy, useClass: HashLocationStrategy)
]);
}
pubspec.yaml
name: bugfix
version: 2.0.0
description: BugFix
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: "^2.2.0"
bootjack: "0.6.7+2"
browser: "^0.10.0+2"
event_bus: "^0.4.1"
less_dart: any
http: "^0.11.3+13"
dart_to_js_script_rewriter: "^1.0.2"
transformers:
- angular2:
platform_directives:
- package:angular2/common.dart#COMMON_DIRECTIVES
platform_pipes:
- package:angular2/common.dart#COMMON_PIPES
entry_points: web/main.dart
- dart_to_js_script_rewriter
- $dart2js:
commandLineOptions: [--enable-experimental-mirrors]
- less_dart:
entry_points: [web/css/main.less]
build_mode: dart
==================
上面的代码实际上是&#34; Bugfix&#34;中的唯一代码。应用。
我做pub get
后跟pub serve --port=8888
。一旦取消注释browser_client
导入,它就会因上述堆栈跟踪而死亡。
答案 0 :(得分:2)
创建了一个最小的回购并要求妻子在她的机器上进行测试(https://github.com/janvladimirmostert/angular-dart-browser-client)并且它对她来说工作正常。
删除飞镖和镖的所有痕迹,并在我的机器上重新安装飞镖,为我修好。
很奇怪: - |