0

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

1 Answer 1

1

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 Something.dart as name.class_name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.