使用 package:http/browser_client.dart 会导致有关镜像的警告

Making use of package:http/browser_client.dart causes warnings about mirrors

在 dart import 'package:http/browser_client.dart'; 中执行以下导入会在执行 pub build

时引起警告
****************************************************************
* WARNING: dart:mirrors support in dart2js is experimental,
*          and not recommended.
*          This implementation of mirrors is incomplete,
*          and often greatly increases the size of the generated
*          JavaScript code.
*
* Your app imports dart:mirrors via:
*   index.html_bootstrap.dart => package:myapp => package:http => dart:mirrors
*
* Starting with Dart 1.9, you must use the
* --enable-experimental-mirrors command-line flag to opt-in.
* You can begin using this flag now if mirrors support is critical.
*
* To learn what to do next, please visit:
*    http://dartlang.org/dart2js-reflection
****************************************************************

[Warning from Dart2JS on myapp|web/index.html_bootstrap.dart]:
3 hint(s) suppressed in package:http.
[Dart2JS on myapp|web/index.html_bootstrap.dart]:
5 warning(s) suppressed in package:myapp.
[Warning from Dart2JS]:
web/index.html_bootstrap.dart:
1 methods retained for use by dart:mirrors out of 2361 total methods (0%).
[Info from Dart2JS on myapp|web/index.html_bootstrap.dart]:
packages/http/src/io.dart:9:1:
Import of 'dart:mirrors'.
import 'dart:mirrors';
^^^^^^^^^^^^^^^^^^^^^^

使用 browser_client 的代码是:

var client = new BrowserClient();
client.post(url, body: req.toString())...

这是我应该关心的事情吗,或者这是那些讨厌的警告之一,除非我停止使用 http 包,否则这些警告不会消失?

更新:

查看内部 browser_client.dart,我看到以下评论:

// TODO(nweiz): Move this under src/, re-export from lib/http.dart, and use this
// automatically from [new Client] once we can create an HttpRequest using
// mirrors on dart2js (issue 18541) and dart2js doesn't crash on pkg/collection
// (issue 18535).

更新:

正在运行 pub help,我看不到这样的标志:

pub help
Pub is a package manager for Dart.

Usage: pub <command> [arguments]

Global options:
-h, --help            Print this usage information.
    --version         Print pub version.
    --[no-]trace      Print debugging information when an error occurs.
    --verbosity       Control output verbosity.

          [all]       Show all output including internal tracing messages.
          [io]        Also show IO operations.
          [normal]    Show errors, warnings, and user messages.
          [solver]    Show steps during version resolution.

-v, --verbose         Shortcut for "--verbosity=all".

Available commands:
  build       Apply transformers to build a package.
  cache       Work with the system cache.
  deps        Print package dependencies.
  downgrade   Downgrade the current package's dependencies to oldest versions.
  get         Get the current package's dependencies.
  global      Work with global packages.
  help        Display help information for Pub.
  publish     Publish the current package to pub.dartlang.org.
  run         Run an executable from a package.
  serve       Run a local web development server.
  upgrade     Upgrade the current package's dependencies to latest versions.
  uploader    Manage uploaders for a package on pub.dartlang.org.
  version     Print pub version.

直接调用,pub告诉我没有这个flag:

 pub build --enable-experimental-mirrors
Could not find an option named "enable-experimental-mirrors".

当你添加它告诉你添加的标志时它就会消失:--enable-experimental-mirrors

如消息所述,镜像当前使生成的 JavaScript 的大小膨胀。这常常让开发人员措手不及,因为他们正确地期望 dart2js 能够正确处理这个问题。然而,对于 dart2js 来说,这是一个非常重要的问题。虽然正在研究更好的解决方案,但镜像支持被认为是实验性的,此警告用于通知开发人员使用它们可能涉及的潜在问题。

您可以添加标志以表示您知道镜像问题并选择使用它们。