Skip to content

Commit

Permalink
Add dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
banghuazhao committed Oct 12, 2024
1 parent f4a6d0f commit 1614fd6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/firebase-hosting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
with:
flutter-version: '3.19.0'

- name: Set environment variables
run: echo "FIREBASE_TOKEN=${{ secrets.FIREBASE_TOKEN }}" >> .env

- name: Clean build
run: flutter clean

Expand All @@ -31,8 +34,6 @@ jobs:
run: flutter build web --verbose

- name: Deploy to Firebase Hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: |
npm install -g firebase-tools
firebase deploy --only hosting --project composites-ai
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ android/fastlane/report.xml
ios/fastlane/report.xml
.firebase
key
.env
Binary file removed Untitled.sketch
Binary file not shown.
4 changes: 2 additions & 2 deletions data/lib/utils/api_constants.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'chat_config.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

class ApiConstants {
static const String baseUrl = 'https://api.openai.com/v1';
static const String chatCompletionsEndpoint = '$baseUrl/chat/completions';
static String apiKey = ChatConfig.apiKey;
static String apiKey = dotenv.env['OPENAI_API_KEY'] ?? "";
}
1 change: 1 addition & 0 deletions data/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
flutter_dotenv: ^5.0.2



Expand Down
Binary file removed instant face.sketch
Binary file not shown.
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
import 'package:swiftcomp/generated/l10n.dart';
Expand All @@ -18,6 +19,8 @@ import 'injection_container.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();

await dotenv.load();

Future.delayed(Duration(seconds: 1), () {
AppTrackingTransparency.requestTrackingAuthorization();
});
Expand All @@ -27,6 +30,7 @@ void main() async {
await SharedPreferencesHelper.init();

initInjection();

runApp(MyApp());
}

Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
file: ^6.1.4
flutter_markdown: ^0.7.3+2
get_it: ^8.0.0
flutter_dotenv: ^5.0.2

amplify_flutter: ^1.8.0
amplify_auth_cognito: ^1.8.0
Expand Down Expand Up @@ -85,6 +86,7 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets:
- images/
- .env

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit 1614fd6

Please sign in to comment.