This file contains hidden or 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:math'; | |
void main() { | |
var rng = new Random(); | |
var testList = List<int>.generate(10, (_) => rng.nextInt(30) - rng.nextInt(10)); | |
print(testList); | |
print(selectionSort(testList)); | |
This file contains hidden or 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()); | |
final config = { | |
'primaryColor': Colors.grey[200], | |
}; | |
class MyApp extends StatelessWidget { | |
@override |
This file contains hidden or 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()); | |
final config = { | |
'primaryColor': Colors.grey[200], | |
}; | |
double myOffset = -200.0; |
This file contains hidden or 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'; | |
Future<dynamic> someFutureResult(){ | |
final Completer c = Completer(); | |
// complete will be called in 3 seconds by the timer. | |
new Timer(Duration(seconds: 3), () => c.complete("you should see me second")); | |
return c.future; | |
} | |
main(){ |
This file contains hidden or 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() { | |
Future<void> tryThings(Stream<int> data) async { | |
try { | |
await for (var x in data) { | |
print("Data: $x"); | |
} | |
} catch (e) { | |
print(e); | |
} | |
} |
This file contains hidden or 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(MaterialApp( | |
home: HomePage(), | |
title: 'Stream Demo', | |
)); | |
} | |
class HomePage extends StatelessWidget { |
This file contains hidden or 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
// asynchronous data | |
main() async { | |
Duration interval = Duration(seconds: 1); | |
Stream<int> stream = Stream<int>.periodic(interval); | |
stream = stream.take(10); | |
print(await stream.length); | |
} |
This file contains hidden or 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
// asynchronous data | |
main() async { | |
Duration interval = Duration(seconds: 1); | |
Stream<int> stream = Stream<int>.periodic(interval,transform); | |
stream = stream.take(10); | |
stream.forEach((int x){ | |
print(x); | |
}); | |
This file contains hidden or 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
// asynchronous data | |
main() async { | |
Duration interval = Duration(seconds: 1); | |
Stream<int> stream = Stream<int>.periodic(interval,transform); | |
stream = stream.take(10); | |
stream.listen((x){ | |
print(x); | |
}); | |
This file contains hidden or 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
// asynchronous data | |
main() async { | |
Duration interval = Duration(seconds: 1); | |
Stream<int> stream = Stream<int>.periodic(interval,transform); | |
stream = stream.take(5); | |
List<int> data = await stream.toList(); | |
for(int i in data){ | |
print(i); | |
} | |
} |
NewerOlder