I'm working on a flutter project and I want to import a dart file in my main file but I don't know how to do it.
I import my dart file first import 'package:splash/Categories.dart';
and I initialized it like that final Category _category = Category();
but I have this error Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports
Please how can I fix it. Thank you in advance
CodePudding user response:
This happens when the same class is in two different files. So if you want to use a specific class in specific file we need to use aliases.
Example:
import 'package:splash/Categories.dart';
import 'package:something/Something.dart' as name;
Use classname in in Something.dart
as name.class_name