feat: Implement platform-specific Google Maps API key handling and update app version.
Some checks failed
Deploy to Play Store / build_and_deploy (push) Has been cancelled

This commit is contained in:
Van Leemput Dayron
2025-12-06 14:43:22 +01:00
parent 34b5efb1fc
commit ca28e0a780
6 changed files with 68 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@@ -84,7 +85,18 @@ class _CreateTripContentState extends State<CreateTripContent> {
String? _selectedImageUrl; String? _selectedImageUrl;
/// Google Maps API key for location services /// Google Maps API key for location services
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? ''; static String get _apiKey {
if (Platform.isAndroid) {
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
} else if (Platform.isIOS) {
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
}
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
}
/// Participant management /// Participant management
final List<String> _participants = []; final List<String> _participants = [];

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
@@ -31,7 +32,18 @@ class _MapContentState extends State<MapContent> {
List<PlaceSuggestion> _suggestions = []; List<PlaceSuggestion> _suggestions = [];
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? ''; static String get _apiKey {
if (Platform.isAndroid) {
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
} else if (Platform.isIOS) {
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
}
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
}
@override @override
void initState() { void initState() {

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
@@ -13,7 +14,19 @@ class ActivityPlacesService {
ActivityPlacesService._internal(); ActivityPlacesService._internal();
final ErrorService _errorService = ErrorService(); final ErrorService _errorService = ErrorService();
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
static String get _apiKey {
if (Platform.isAndroid) {
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
} else if (Platform.isIOS) {
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
}
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
}
/// Recherche des activités près d'une destination /// Recherche des activités près d'une destination
Future<List<Activity>> searchActivities({ Future<List<Activity>> searchActivities({

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
@@ -5,7 +6,19 @@ import 'package:firebase_storage/firebase_storage.dart';
import 'package:travel_mate/services/error_service.dart'; import 'package:travel_mate/services/error_service.dart';
class PlaceImageService { class PlaceImageService {
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? ''; static String get _apiKey {
if (Platform.isAndroid) {
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
} else if (Platform.isIOS) {
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
}
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
}
final FirebaseStorage _storage = FirebaseStorage.instance; final FirebaseStorage _storage = FirebaseStorage.instance;
final ErrorService _errorService = ErrorService(); final ErrorService _errorService = ErrorService();

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
@@ -13,7 +14,18 @@ class TripGeocodingService {
TripGeocodingService._internal(); TripGeocodingService._internal();
final ErrorService _errorService = ErrorService(); final ErrorService _errorService = ErrorService();
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? ''; static String get _apiKey {
if (Platform.isAndroid) {
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
} else if (Platform.isIOS) {
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
'';
}
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
}
/// Géocode la destination d'un voyage et retourne un Trip mis à jour /// Géocode la destination d'un voyage et retourne un Trip mis à jour
Future<Trip> geocodeTrip(Trip trip) async { Future<Trip> geocodeTrip(Trip trip) async {

View File

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 1.0.1+2
environment: environment:
sdk: ^3.9.2 sdk: ^3.9.2