The canonicalFor directive is possibly the last part of the Dart SDK that relies on giving a library a name. Everything else has at least a different alternative for unnamed libraries.
There is no other reason to give a library a name, and using library names is generally considered "so last decade!", so it irks when you have to go write a library name just to use canonicalFor.
The canonicalFor directive should introduce a different way to refer to a library.
I'd recommend:
{@canonicalFor DeclName}, where DeclName denotes the declaration actually exported by this library by that name. That should be unique and always what you want.
{@canonicalFor package:whatnot/entry.dart DeclName} or * {@canonicalFor package:whatnot/entry.dart#DeclName} if you want to denote the library. URIs is how you denote a library. But really shouldn't be necessary, the first option should always be the right one.
The
canonicalFordirective is possibly the last part of the Dart SDK that relies on giving a library a name. Everything else has at least a different alternative for unnamed libraries.There is no other reason to give a library a name, and using library names is generally considered "so last decade!", so it irks when you have to go write a library name just to use
canonicalFor.The
canonicalFordirective should introduce a different way to refer to a library.I'd recommend:
{@canonicalFor DeclName}, whereDeclNamedenotes the declaration actually exported by this library by that name. That should be unique and always what you want.{@canonicalFor package:whatnot/entry.dart DeclName}or *{@canonicalFor package:whatnot/entry.dart#DeclName}if you want to denote the library. URIs is how you denote a library. But really shouldn't be necessary, the first option should always be the right one.