Skip to content

Instantly share code, notes, and snippets.

@it-one-mm
Last active January 13, 2021 09:12
Show Gist options
  • Save it-one-mm/9f66fffcb5d395b2c88655b8d611217b to your computer and use it in GitHub Desktop.
Save it-one-mm/9f66fffcb5d395b2c88655b8d611217b to your computer and use it in GitHub Desktop.
Dart Sample
void main() {
for(int i = 1; i <= 5; i++) {
print('hello $i');
}
print('finish loop');
// i i < 5 i++
// 0 0 < 5 Hello 0
// 1
// 1 < 5 Hello 1
// 2
// 2 < 5 Hello 2
// for(int i=99; i>0; i--) {
// print('$i bottles of beer on the wall, $i bottles of beer.');
// if (i > 1) {
// print('Take one down and pass it around, ${i - 1} bottles of beer on the wall.');
// }
// }
// List<String> fruits = [
// 'apple',
// 'orange',
// 'grape',
// 'pieapple',
// 'strawberry',
// ];
// for (String fruit in fruits) {
// print(fruit);
// }
}
import 'dart:async';
void main() {
StreamSubscription _sub;
print('Start Timer');
_sub = Stream.periodic(Duration(seconds: 2), (val) {
print(val);
if (val == 4) {
print('End Timer');
_sub?.cancel();
}
}).listen((event) {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment