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:convert'; | |
import 'dart:html'; | |
void main() { | |
_getIPAddress() async { | |
final url = 'https://httpbin.org/ip'; | |
var request = await HttpRequest.request(url); | |
String ip = json.decode(request.responseText)['origin']; | |
print(ip); | |
} |
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:convert'; | |
import 'dart:html'; | |
void main() { | |
_getIPAddress() { | |
final url = 'https://httpbin.org/ip'; | |
Future<HttpRequest> request = HttpRequest.request(url); | |
request.then((value) { | |
print(json.decode(value.responseText)['origin']); | |
}).catchError((error) => print(error)); |
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 printInts(List<int> a) => print(a); | |
void main() { | |
var list = <int>[]; // Removing <int> results in a type error | |
list.add(1); | |
list.add(2); | |
printInts(list); | |
} |
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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, 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. | |
--> | |
<html> |
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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, 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. | |
--> | |
<html> |
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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, 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. | |
--> |
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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, 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. | |
--> |
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 uri = Uri.parse('https://foo.bar.com/this/is/a/path?foo=foo1&foo=foo2&bar=baz'); | |
print(uri); | |
print(uri.queryParameters); | |
// print(uri.queryParametersAll); // -> uncomment to see type error | |
} |
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
// From https://www.dartlang.org/guides/language/language-tour#restricting-the-parameterized-type | |
class SomeBaseClass {} | |
// T must be SomeBaseClass or one of its descendants. | |
class Foo<T extends SomeBaseClass> { | |
String toString() => 'Foo<$T>'; | |
} | |
class Extender extends SomeBaseClass {} |
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 { |
NewerOlder