feat: Integrate dotenv for environment variable management and update .gitignore

This commit is contained in:
Dayron
2025-10-20 01:45:55 +02:00
parent d41e6ff6db
commit f98f81f2f7
5 changed files with 18 additions and 3 deletions

3
.gitignore vendored
View File

@@ -45,3 +45,6 @@ app.*.map.json
/android/app/release
.vscode
.VSCodeCounter
.env
.env.local
.env.*.local

View File

@@ -4,6 +4,7 @@ import 'package:geolocator/geolocator.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'dart:ui' as ui;
import 'package:flutter_dotenv/flutter_dotenv.dart';
class MapContent extends StatefulWidget {
const MapContent({super.key});
@@ -25,7 +26,7 @@ class _MapContentState extends State<MapContent> {
List<PlaceSuggestion> _suggestions = [];
static const String _apiKey = 'AIzaSyBPxanjGyrWVjI4-hZmi086VdQFSEYT_2U';
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
@override
void initState() {

View File

@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:travel_mate/services/error_service.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'blocs/auth/auth_bloc.dart';
import 'blocs/auth/auth_event.dart';
import 'blocs/auth/auth_state.dart';
import 'blocs/theme/theme_bloc.dart';
import 'blocs/theme/theme_event.dart';
import 'blocs/theme/theme_state.dart';
@@ -22,6 +22,7 @@ import 'pages/resetpswd.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
await Firebase.initializeApp();
runApp(const MyApp());

View File

@@ -246,6 +246,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "9.1.1"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: d4130c4a43e0b13fefc593bc3961f2cb46e30cb79e253d4a526b1b5d24ae1ce4
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_lints:
dependency: "direct dev"
description:

View File

@@ -50,6 +50,7 @@ dependencies:
geolocator: ^14.0.2
google_places_flutter: ^2.1.1
http: ^1.5.0
flutter_dotenv: ^6.0.0
dev_dependencies:
flutter_test:
@@ -76,6 +77,7 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets:
- assets/icons/
- .env
#- assets/images/
# An image asset can refer to one or more resolution-specific "variants", see