Skip to content

Instantly share code, notes, and snippets.

@esarbanis esarbanis/lib_repository.dart Secret
Last active Aug 22, 2019

Embed
What would you like to do?
//This file is in `./lib` folder
import 'package:http/http.dart' show Client;
import '.env.dart';
class Repository {
final String _baseUrl = environment.baseUrl;
Client _client;
DebtorRepository() {
this._client = Client();
}
// For simplicity's sake we will not deal with json encoding/decoding
Future<any> info(String token) async {
return await this._client.get('$_baseUrl/info');
}
}
#!/bin/bash
dart tool/env.dart
//This file is in `./tool` folder
import 'dart:convert';
import 'dart:io';
Future<void> main() async {
final config = {
'baseUrl': Platform.environment['APP_BASE_URL'],
'credentials': Platform.environment['APP_CREDENTIALS'],
};
final filename = 'lib/.env.dart';
File(filename).writeAsString('final environment = ${json.encode(config)};');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.