Skip to content

Commit

Permalink
add .env
Browse files Browse the repository at this point in the history
  • Loading branch information
Dat-TG committed Dec 10, 2023
1 parent 94f8b08 commit 04c179b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ build/
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
.flutter-plugins-dependencies
ios/Flutter/flutter_export_environment.sh

# Evironment variables
.env
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import 'package:boilerplate/di/service_locator.dart';
import 'package:boilerplate/presentation/my_app.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await setPreferredOrientations();
await ServiceLocator.configureDependencies();
await dotenv.load(fileName: '.env');
runApp(MyApp());
}

Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/new_chat/new_chat_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:boilerplate/core/widgets/chat_input.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_svg/flutter_svg.dart';

class NewChatScreen extends StatefulWidget {
Expand Down Expand Up @@ -43,7 +44,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
height: 10,
),
Text(
'How can I help you today?',
'How can I help you today? ${dotenv.env['OPEN_API_ACCESS_KEY']}',
style: Theme.of(context).textTheme.titleLarge,
),
],
Expand Down
28 changes: 14 additions & 14 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: A flutter boilerplate project created using MobX and Provider.
version: 1.0.0+1

environment:
sdk: '>=3.0.6 <4.0.0'
sdk: ">=3.0.6 <4.0.0"

dependencies:
flutter:
sdk: flutter
Expand Down Expand Up @@ -65,6 +65,7 @@ dependencies:
font_awesome_flutter: ^10.6.0
flutter_svg: ^2.0.9
emoji_picker_flutter: ^1.6.3
flutter_dotenv: ^5.1.0
# Y
# Z

Expand All @@ -86,23 +87,22 @@ flutter_icons:
android: true
ios: true


# For information on the generic Dart art of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
- assets/icons/
- assets/lang/
- assets/images/
- assets/icons/
- assets/lang/
- .env

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
Expand All @@ -116,13 +116,13 @@ flutter:
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: ProductSans
fonts:
- asset: assets/fonts/Product-Sans-Regular.ttf
- asset: assets/fonts/Product-Sans-Italic.ttf
style: italic
- asset: assets/fonts/Product-Sans-Bold.ttf
weight: 700
- family: ProductSans
fonts:
- asset: assets/fonts/Product-Sans-Regular.ttf
- asset: assets/fonts/Product-Sans-Italic.ttf
style: italic
- asset: assets/fonts/Product-Sans-Bold.ttf
weight: 700

# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages

0 comments on commit 04c179b

Please sign in to comment.