Skip to content

Instantly share code, notes, and snippets.

@kwalrath
Last active September 9, 2015 17:05
Show Gist options
  • Save kwalrath/a6907e26b96678b75303 to your computer and use it in GitHub Desktop.
Save kwalrath/a6907e26b96678b75303 to your computer and use it in GitHub Desktop.
homepage_jw
import 'dart:html' show HttpRequest;
main() async {
// Asychronously get text to display.
var lines = await getLines();
// If result is non-null, print it.
lines?.forEach((line) => print(line));
}
// Reads a file, returning all lines with the string
// 'jabberwock'.
getLines() async {
var jabber = await HttpRequest.getString(
'https://www.dartlang.org/f/jabberwocky.txt');
var lines = jabber.split('\n');
lines.retainWhere((line) =>
line.toLowerCase().contains('jabberwock'));
return lines;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment