【问题标题】:Why do I see :" import of dart:mirrors is not supported in the current Dart runtime"为什么我会看到:\"当前 Dart 运行时不支持导入 dart:mirrors\"
【发布时间】:2023-01-22 20:16:40
【问题描述】:
Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
[ERROR:flutter/shell/common/shell.cc(89)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
[ERROR:flutter/runtime/dart_isolate.cc(144)] Could not prepare isolate.
[ERROR:flutter/runtime/runtime_controller.cc(417)] Could not create root isolate.
[ERROR:flutter/shell/common/shell.cc(606)] Could not launch engine with configuration.

当我运行程序时,我看到这样的错误......

【问题讨论】:

    标签: flutter


    【解决方案1】:

    dart:mirrors 库用于 Dart 中的运行时反射,它允许您在程序运行时检查程序的结构和行为。然而,目前正在使用的 Dart 运行时不支持这个库,

    这是因为 dart:mirrors 库是一项实验性功能,不是稳定版 Dart SDK 的一部分,默认情况下未启用。 dart:mirrors 库仍在开发中,在生产运行时环境中未启用。

    您应该避免在生产代码中使用 dart:mirrors,而是使用其他技术在运行时检查和操作您的程序,例如使用 dart:core 库的 dart:is 函数进行运行时类型检查。

    如果你真的想使用 dart:mirrors 库,你可以在运行代码时通过将 --enable-experiment=mirrors 标志传递给 Dart VM 来启用它。

    【讨论】:

      猜你喜欢
      • 2020-02-16
      • 1970-01-01
      • 2022-08-16
      • 2013-06-29
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2019-09-17
      • 2013-11-21
      相关资源
      最近更新 更多