Created
November 25, 2019 20:41
-
-
Save r3dm1ke/35cb2087d3f4ec9d28778a1dbc6f63cd to your computer and use it in GitHub Desktop.
Deferred imports in Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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