Created
August 30, 2023 15:23
-
-
Save av1v3k/9e0848e323ce7d5b09a7a1f7a6881716 to your computer and use it in GitHub Desktop.
Usage of delayed() method with Future; Duration() in dart.
This file contains hidden or 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
//use of async, await, futures in dart | |
import 'dart:async'; | |
void main() async { | |
var data = await get('hi'); | |
print(data); | |
} | |
Future<String> get(String url) { | |
return Future.delayed(const Duration(seconds: 3), () { | |
return 'Hello user!'; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment