use .env for key instead of hardcoding (and rotate key)

This commit is contained in:
2025-04-20 20:52:38 -07:00
parent 412007d34a
commit 709de36640
2 changed files with 9 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
class Debouncer {
final int milliseconds;
@@ -17,3 +19,7 @@ class Debouncer {
_timer?.cancel();
}
}
String getGooglePlacesApiKey() {
return dotenv.env['GMS_API_KEY'] ?? Platform.environment['GMS_API_KEY'] ?? "";
}

View File

@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart' as gmaps;
import 'package:flutter_google_places_sdk/flutter_google_places_sdk.dart'
as places;
import 'package:wheres_my_sign/common/constants.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:wheres_my_sign/common/functions.dart';
import 'dart:async';
import 'package:wheres_my_sign/models/property.dart';
@@ -35,9 +35,10 @@ class CustomDialogBoxState extends State<CustomDialogBox> {
final _addressFocusNode = FocusNode();
Timer? _debouncer;
List<places.AutocompletePrediction> _predictions = [];
String apiKey = getGooglePlacesApiKey();
final places.FlutterGooglePlacesSdk _places = places.FlutterGooglePlacesSdk(
'AIzaSyBLSUk32a5qGm3M_n9Yii66I7wi0rmA8oM',
getGooglePlacesApiKey(),
);
late Property property; // Declare property to store final details