Last active
January 13, 2021 09:12
-
-
Save it-one-mm/9f66fffcb5d395b2c88655b8d611217b to your computer and use it in GitHub Desktop.
Dart Sample
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
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); | |
// } | |
} |
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 '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