Skip to content

Instantly share code, notes, and snippets.

@chalin
Last active December 5, 2018 18:20
Show Gist options
  • Save chalin/5a0017d09b6823d0248d965b93133e2e to your computer and use it in GitHub Desktop.
Save chalin/5a0017d09b6823d0248d965b93133e2e to your computer and use it in GitHub Desktop.
Flutter for React Native devs: Dart Futures
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));
}
_getIPAddress();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment