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
# Clicking on each link yields: | |
number.value => '' | |
number.valueAsNumber => NaN | |
number.valueAsDate => Exception: NullError: Cannot call "getTime" on null | |
date.value => '' | |
date.valueAsNumber => NaN | |
date.valueAsDate => Exception: NullError: Cannot call "getTime" on null | |
time.value => '' | |
time.valueAsNumber => NaN | |
time.valueAsDate => Exception: NullError: Cannot call "getTime" on null |
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:html'; | |
void main() { | |
var div = document.createElement('div'); | |
print('1. div.style.fontSize = ${div.style.fontSize}'); | |
div.style.fontSize = "120%"; | |
print('2. div.style.fontSize = ${div.style.fontSize}'); | |
/* | |
* div.style[] results in warning: | |
* The operator '[]=' is not defined for the class 'CssStyleDeclaration'. |
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
main() => print(new Object() == new Object()); |
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() { | |
thingsTodo().forEach(print); | |
} | |
Iterable<String> thingsTodo() sync* { | |
var actions = ['Walk', 'Wash', 'Feed']; | |
var pets = ['cats', 'dogs']; | |
for (var action in actions) { | |
for (var pet in pets) { |
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
typedef FooOrig<T>(T a); | |
typedef FooNew1 = T Function<T>(T a); | |
typedef FooNew2<T> = T Function(T a); | |
typedef FooNew3<T> = T Function<T>(T a); | |
// DECLARATION // STATIC TYPE | |
FooOrig vf_orig0; // (dynamic) → dynamic | |
FooOrig<int> vf_orig1; // (int) → dynamic | |
T Function<T>(T a) vf_new; // <T>(T) → T | |
FooNew1 vf_new1a; // <T>(T) → T |
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() { | |
var list = ['apples', 'bananas', 'oranges']; | |
list.forEach((item) { | |
print('${list.indexOf(item)}: $item'); | |
}); | |
} |
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
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'dart:async'; | |
printDailyNewsDigest() async { | |
String news = await gatherNewsReports(); | |
print(news); | |
} |
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
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'dart:async'; | |
printDailyNewsDigest() { | |
final future = gatherNewsReports(); | |
future.then((news) => print(news)); | |
} |
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
main () { | |
List<dynamic> strings = ["not", "ints"]; | |
List<int> numbers = strings; // <- strong mode error? | |
for (var number in numbers) { | |
print(number - 10); // <— Boom! | |
} | |
} |
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
// Copyright (c) 2015, the Dart project authors. | |
// Please see the AUTHORS file for details. | |
// All rights reserved. Use of this source code is governed | |
// by a BSD-style license that can be found in the LICENSE file. | |
import 'dart:async'; | |
Future<int> sumStream(Stream<int> stream) async { | |
var sum = 0; | |
try { |
OlderNewer