Skip to content

Instantly share code, notes, and snippets.

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');
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)};');

This comment has been minimized.

Copy link

@nimi0112 nimi0112 commented Jan 8, 2021

Hi @esarbanis do you have any sample project for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment