Dart错误:错误:使用--enable-mirrors = false导入dart:mirrors [英] Dart Error: error: import of dart:mirrors with --enable-mirrors=false

查看:149
本文介绍了Dart错误:错误:使用--enable-mirrors = false导入dart:mirrors的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.yaml文件下面:

.yaml file bellow:

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2
  fluttertoast: ^2.0.9
  dio: ^1.0.6
  json_serializable: ^2.0.0
dev_dependencies:
  build_runner: ^1.0.0
  json_annotation: ^2.0.0

当我运行时:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
D/OpenGLRenderer( 5350): HWUI GL Pipeline
I/OpenGLRenderer( 5350): Initialized EGL, version 1.4
D/OpenGLRenderer( 5350): Swap behavior 1
D/        ( 5350): HostConnection::get() New Host Connection established 
0xa12b3ec0, tid 5379
D/EGL_emulation( 5350): eglCreateContext: 0xa127cf60: maj 2 min 0 rcv 2
D/        ( 5350): SurfaceInterface::setAsyncMode: set async mode 1
D/EGL_emulation( 5350): eglMakeCurrent: 0xa127cf60: ver 2 0 (tinfo         
0xa177fe80)
E/flutter ( 5350): [ERROR:flutter/shell/common/shell.cc(188)] Dart Error: 
error: import of dart:mirrors with --enable-mirrors=false
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(176)] Could not 
prepare to run the isolate.
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(123)] Engine not prepare and launch isolate.
E/flutter ( 5350): 
[ERROR:flutter/shell/platform/android/android_shell_holder.cc(167)] Could not launch engine in configuration.






我知道问题是 json_serializable但我不知道该如何解决。还是有什么方法可以在模型和json之间转换


i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json

推荐答案

在解决您的问题后,我在自己的搜索中偶然发现了您的帖子问题。

I did stumble across your post on my own search after solutions with your problem.

我假设您要使用 json_serializable 来创建自己的sourceCode。
如果是这种情况,则您应该在 dev_dependencies 下使用
json_serializable:^ 2.0.0
code>。

I assume that you want to use json_serializable for your own sourceCode creation. If this is the case you should have json_serializable: ^2.0.0 under the dev_dependencies.

json_serializable 确实在内部使用 dartlang / source_gen
source_gen 确实引用了 dart:mirrors ,在flutter中不受支持(如这篇文章)。

json_serializable does use dartlang/source_gen internally. source_gen in turn does reference dart:mirrors, which is not supported in flutter (as told in this post).

简而言之,这么长的话:
-通过从 build依赖项中删除对 json_serializable 的依赖性,您将删除对镜像的依赖性,这将停止flutterBuild。




So long story in short: - through removing the dependency on json_serializable from your "build" dependencies you remove the dependency on mirrors which is stopping your flutterBuild.


我知道问题是 json_serializable,但我不知道如何解决。还是有什么方法可以在模型和json之间进行转换

i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json

我没有真正了解这一部分。
至少对我而言,这还不足以为您的模型生成提供帮助。

I did not really got that part. At least for me this is not enough information to provide help on your modelgeneration.

如果您发布使用<$ c $的课程,可以尝试c> json_serializable 和生成的部分类。

Could try if you post a class in which you use json_serializable and the generated partial class.

这篇关于Dart错误:错误:使用--enable-mirrors = false导入dart:mirrors的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆