我正在做一個顫振專案,我想在我的主檔案中匯入一個飛鏢檔案,但我不知道該怎么做。我先匯入我的 dart 檔案import 'package:splash/Categories.dart';
,然后像這樣初始化它,final Category _category = Category();
但是我有這個錯誤,請問我該Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports
如何修復它。先感謝您
uj5u.com熱心網友回復:
當同一個類位于兩個不同的檔案中時,就會發生這種情況。因此,如果您想在特定檔案中使用特定類,我們需要使用別名。
例子:
import 'package:splash/Categories.dart';
import 'package:something/Something.dart' as name;
在中使用類名Something.dart作為name.class_name
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/425583.html
