Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Created November 25, 2019 20:41
Show Gist options
  • Save r3dm1ke/35cb2087d3f4ec9d28778a1dbc6f63cd to your computer and use it in GitHub Desktop.
Save r3dm1ke/35cb2087d3f4ec9d28778a1dbc6f63cd to your computer and use it in GitHub Desktop.
Deferred imports in Dart
// Importing standart math library
// Note that with deferred imports we have to specify its name
// using _is_ keyword
import 'dart:math' deferred as math;
void main() {
greet();
}
// This is a function that is async. I will talk about
// these kind of functions later on
Future greet() async {
// Actually loading the library
await math.loadLibrary();
// Using it
print(math.sin(0));
}
@softmarshmallow
Copy link

What is this deferred keyword does?
Why is it required since dart is compile time language, I don't quite get the concept of delayed or dynamic import on dartlang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment