Skip to content

Instantly share code, notes, and snippets.

@av1v3k
Created August 30, 2023 15:23
Show Gist options
  • Save av1v3k/9e0848e323ce7d5b09a7a1f7a6881716 to your computer and use it in GitHub Desktop.
Save av1v3k/9e0848e323ce7d5b09a7a1f7a6881716 to your computer and use it in GitHub Desktop.
Usage of delayed() method with Future; Duration() in dart.
//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