import 'dart:async';
Stream get asynchronousNaturals async* {
print("Begin");
int k = 0;
while (k < 3) {
print("Before Yield");
yield k++;
}
print("End");
}
void testAsync() {
StreamSubscription subscription = asynchronousNaturals.listen(null);
subscription.onData((value) {
print(value);
//subscription.pause();
});
}
main() {
var numbers = [1, 2.3, 4]; // List<num>.
numbers.removeAt(1); // Now it only contains integers.
var ints = new List<int>.from(numbers);
print(ints);
var map1 = {
"first": ["Dart", "aaaa"],
1: true,
true: "2"
};
print(map1);
//List list = (map1["first"] as List)?.map((e) => print(e))?.toList();
print(map1["first"].runtimeType);
if (map1["first"] is List) {
List list = map1["first"] as List;
print(list);
}
var a = [1, 2, 'three'];
print(a is List); // True
print(a is List<int>); //真的!
print(a is List<String>); //真的!
var b = new List<int>.from([1, 2, 3]);
print(b is List); // True
print(b is List<int>); // True
print(b is List<String>); // False
}
运行结果
[Running] dart "d:\mygo\mydart\async_star_sub.dart"
[1, 4]
{first: [Dart, aaaa], 1: true, true: 2}
List<String>
[Dart, aaaa]
true
false
false
true
true
false