iDecode
iDecode

Reputation: 28986

How to use "as" while exporting a library?

I've a file, foo.dart which is exporting some libraries.

export 'dart:convert'; // Works
export 'dart:math' as math; // Error

But as you can see there's an error while using as in export.

Upvotes: 0

Views: 222

Answers (1)

lrn
lrn

Reputation: 71773

You cannot export a namespace.

Exports cannot have an as. The effect of an as prefix on an import is to declare a namespace in the library and import the imported library into that namespace. There is nothing similar you can do for exports because you cannot export a namespace at all, the concept does not exist in the language. You can only export declarations.

This also prevents nested namespaces, which you could get if you could export a namespace, and then import or export it with a new prefix as well.

Upvotes: 1

Related Questions