Import class final
Define a platform specific import with auto-generated stubbing.
You can use the Import.onWeb or Import.onServer variants for web and server specific imports, respectively.
The following example is equivalent to import 'dart:html' show window,
but does not lead to a compilation error on the server:
@Import.onWeb('dart:html', show: [#window])
import 'file.imports.dart';
- Put the actual import in the annotation.
- Define what elements or types to 'show' as symbols (prefixed by #).
- This is required to reduce the amount of stubbing needed.
- Import the file '<current filename>.imports.dart'.
The associated file will be generated the next time you run jaspr serve.
Make sure to use the imported elements and types only after
the appropriate platform check using kIsWeb. For example:
if (kIsWeb) {
print(window.name);
}
Accessing your imported elements on the wrong platform will result in runtime exceptions.
Constructors
- Import.onServer(String import, {required List show})
-
const
- Import.onWeb(String import, {required List show})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- import → String
-
final
- platform → ImportPlatform
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- show → List
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited