警告“导入的库在它们不”时具有相同的名称 [英] Warning that 'imported libraries have the same name when they DO NOT"

查看:132
本文介绍了警告“导入的库在它们不”时具有相同的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在类中有以下import语句

I have the following import statements in a class

import 'package:dart_web_toolkit/ui.dart';

import '../../util/flex_table_builder.dart' as ftBldr;

import '../factors_list_view.dart';


class MediatingFactorsView extends Composite
{
 //... 
}

但是,最后一个导入语句被标记为警告:

However, the last import statment is flagged with a warning:

The different imported libraries 'flex_table_builder.dart' and 'factors_list_view.dart' should not have the same name

名称是完全不同的,我看到这一点在我更新到最新的Dart编辑器后,我的代码。这是一个错误吗?

The names are quite different and I see this being repeated throughout my code after I updated to the latest Dart Editor. Is this a bug?

推荐答案

确保您为每个文件分配库名。文件的第一行应该是:

Make sure that you are assigning library names to each file. The first line of the file should be:

library foo;

您应该为每个库使用不同的名称。库名由 library 指令指定,但匿名库被视为具有相同的名称,这是警告来源。

You should use different names for each library that you use. The library name is specified by the library directive, but anonymous libraries are treated as having the same name, which is where the warning comes from.

这是 Dart规范中的一条警告,用于导入两个库

It is a warning in the Dart specification to import two libraries with the same name.

有关如何使用库的更多信息,请参阅语言导览

You can read more about how to use libraries here in the language tour.

这篇关于警告“导入的库在它们不”时具有相同的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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