refactor: redo the environment system.

This commit is contained in:
Aunali321 2022-10-17 16:48:39 +05:30
parent 603917d21e
commit 273aa42b17
7 changed files with 12 additions and 25 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
sentryDSN=
apiKey=
appId=

View File

@ -22,7 +22,7 @@ jobs:
- uses: SpicyPizza/create-envfile@v1
with:
envkey_sentryDSN: ${{ secrets.SENTRY_DSN }}
evykey_apiKey: ${{ secrets.API_KEY }}
envkey_apiKey: ${{ secrets.API_KEY }}
envkey_appId: ${{ secrets.APP_ID }}
- name: Set up Flutter
run: flutter pub get

1
.gitignore vendored
View File

@ -139,4 +139,3 @@ Firebase related
# Environment variables
android/app/google-services.json
/lib/utils/env_class.g.dart

View File

@ -3,7 +3,7 @@
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
import 'package:revanced_manager/utils/env_class.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
/// Default [FirebaseOptions] for use with your Firebase apps.
///
@ -54,8 +54,8 @@ class DefaultFirebaseOptions {
}
static FirebaseOptions android = FirebaseOptions(
apiKey: Env.apiKey,
appId: Env.appId,
apiKey: dotenv.env['apiKey'] ?? '',
appId: dotenv.env['appId'] ?? '',
messagingSenderId: '1006104807752',
projectId: 'revanced-manager',
storageBucket: 'revanced-manager.appspot.com',

View File

@ -9,14 +9,15 @@ import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:revanced_manager/utils/env_class.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:timezone/data/latest.dart' as tz;
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
Future main() async {
await dotenv.load(fileName: ".env");
await ThemeManager.initialise();
await setupLocator();
WidgetsFlutterBinding.ensureInitialized();
@ -45,7 +46,7 @@ Future main() async {
await SentryFlutter.init(
(options) {
options
..dsn = isSentryEnabled ? Env.sentryDSN : ''
..dsn = isSentryEnabled ? dotenv.env['sentryDSN'] : ''
..environment = 'alpha'
..release = '0.1'
..tracesSampleRate = 1.0

View File

@ -1,15 +0,0 @@
import 'package:envied/envied.dart';
part 'env_class.g.dart';
@Envied()
abstract class Env {
@EnviedField(varName: 'sentryDSN')
static String sentryDSN = _Env.sentryDSN;
@EnviedField(varName: 'apiKey')
static String apiKey = _Env.apiKey;
@EnviedField(varName: 'appId')
static String appId = _Env.appId;
}

View File

@ -73,9 +73,9 @@ dependencies:
url_launcher: ^6.1.5
wakelock: ^0.6.2
sentry_dio: ^6.12.2
envied: ^0.2.3
firebase_core: ^1.24.0
firebase_crashlytics: ^2.9.0
flutter_dotenv: ^5.0.2
dev_dependencies:
json_serializable: ^6.3.1
@ -85,7 +85,6 @@ dev_dependencies:
flutter_test:
sdk: flutter
injectable_generator: ^1.5.4
envied_generator: ^0.2.3