I get a runtime error that reads something like this:
Unhandled exception:
type 'A' is not a subtype of type 'A' of 'x' where
A is from file:///path/to/source/a.dart
A is from package:my_package/a.dart
A
is the exact same type as the other A
-- there is no naming conflict.
The two indented lines ('A is from ...') only differ in their way of specifying the path. One goes through 'package:' and the second one is the file path on the file system.
Use import 'package:...'
everywhere, even when importing files from your own package.
The two URLs (file:///...
and package:...
) are equivalent but Dart has no way of knowing that. When you import source via both relative path and via the package:
scheme, you'll get this error.
To fix this issue, make sure to be consistent in how you import files in your own package.
In file foo.dart:
import '../path/to/a.dart';
In file bar.dart:
import 'package:my_package/a.dart';
This results in an error.
In file foo.dart:
import 'package:my_package/a.dart';
In file bar.dart:
import 'package:my_package/a.dart';
This will be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With