Last active
August 14, 2020 14:50
-
-
Save nsmirosh/924e9ae4504a898497d6db32ae4e2abb to your computer and use it in GitHub Desktop.
event loop process demonstration
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
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: RaisedButton( | |
onPressed: () { | |
print("first event is processed by the event loop!"); | |
Future.delayed(Duration(seconds: 3), () => "completed Future value") | |
.then((value) { | |
print("second event is processed by the event loop!"); | |
print('Future completed with a value : $value'); | |
}); | |
}, | |
child: Text("click me!")), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment