简体   繁体   English

Flutter:如何查找错误位置,构建错误,未找到:'dart:html'?

[英]Flutter: How to find location for error, Build error, Not found: 'dart:html'?

I know this is due to some web libraries accidentally imported to the mobile section, but where?我知道这是由于一些 web 库意外导入到移动部分,但是在哪里? There's no file or code line is mentioned within the project which is causing the issue.项目中没有提到导致问题的文件或代码行。 My project is very huge with a lot of dependencies.我的项目非常庞大,有很多依赖项。 I have both mobile and web-specific code files separately.我分别拥有移动和特定于 Web 的代码文件。 I think I have mixed at any point and now unable to find the location where's it happening.我想我在任何时候都混合过,现在无法找到它发生的位置。

Any method to figure it out?有什么方法可以弄清楚吗? Is there any method to specifically debug the file which is causing the error??有什么方法可以专门调试导致错误的文件吗?

    ../../../../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/top_level.dart:1:8: Error: Not found: 'dart:html'
    import 'dart:html';
           ^

dart:html is only for web and since you cannot build apk or ios with it due to its hinderance and also want to use it due to web,so I would suggest you another solution which works perfectly. dart:html is only for web and since you cannot build apk or ios with it due to its hinderance and also want to use it due to web,so I would suggest you another solution which works perfectly.

Use universal_html : A 'dart:html' that works in all platforms, including Flutter and server-side.使用universal_html :适用于所有平台的“dart:html”,包括 Flutter 和服务器端。 Eases cross-platform development and HTML / XML processing.简化跨平台开发和 HTML / XML 处理。

dependencies:
universal_html: ^2.0.8

Replace import 'dart:html' as html;import 'dart:html' as html; with

import 'package:universal_html/html.dart' as html;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM