Skip to content

Instantly share code, notes, and snippets.

@hjJunior
Created June 10, 2019 19:20
Show Gist options
  • Save hjJunior/868fb252d949b9d697d43cbeaf81d601 to your computer and use it in GitHub Desktop.
Save hjJunior/868fb252d949b9d697d43cbeaf81d601 to your computer and use it in GitHub Desktop.
Using IoC
class MyIp {
Injector get _injector => Injector.getInjector();
Client get _client => _injector.get<Client>();
Future<String> get ipAddress async {
final apiResult = await _client.get('https://api.ipify.org/?format=json');
return json.decode(apiResult.body)['ip'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment