-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WEBSERVER_HOST="http://:::3000" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WEBSERVER_HOST="https://www.tabnews.com.br" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:tabnews/src/app.dart'; | ||
import 'package:tabnews/src/enviroment_vars.dart'; | ||
import 'package:tabnews/src/preferences.dart'; | ||
|
||
void main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
|
||
await Preferences.init(); | ||
|
||
await EnviromentVars.init(useProdEnv: true); | ||
|
||
runApp(const App()); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
|
||
class EnviromentVars { | ||
static late EnviromentVars _singleton; | ||
static EnviromentVars get getVars => _singleton; | ||
|
||
late final String _webserver; | ||
String get webserver => _webserver; | ||
|
||
late final bool _debugEnv; | ||
bool get debugEnv => _debugEnv; | ||
|
||
static Future init({bool useProdEnv = false}) async { | ||
bool devEnviroment = kDebugMode && !useProdEnv; | ||
dotenv = DotEnv(); | ||
|
||
if (devEnviroment) { | ||
await dotenv.load(fileName: ".env.dev"); | ||
} else { | ||
await dotenv.load(fileName: ".env.prod"); | ||
} | ||
|
||
_singleton = EnviromentVars(); | ||
_singleton._webserver = | ||
dotenv.get("WEBSERVER_HOST", fallback: "www.tabnews.com.br"); | ||
_singleton._debugEnv = devEnviroment; | ||
} | ||
} |
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
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
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
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
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