diff --git a/lib/common/functions.dart b/lib/common/functions.dart index 55ace76..c3d3210 100644 --- a/lib/common/functions.dart +++ b/lib/common/functions.dart @@ -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'] ?? ""; +} diff --git a/lib/widgets/custom_dialog_box.dart b/lib/widgets/custom_dialog_box.dart index bfee2e5..8471e4c 100644 --- a/lib/widgets/custom_dialog_box.dart +++ b/lib/widgets/custom_dialog_box.dart @@ -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 { final _addressFocusNode = FocusNode(); Timer? _debouncer; List _predictions = []; + String apiKey = getGooglePlacesApiKey(); final places.FlutterGooglePlacesSdk _places = places.FlutterGooglePlacesSdk( - 'AIzaSyBLSUk32a5qGm3M_n9Yii66I7wi0rmA8oM', + getGooglePlacesApiKey(), ); late Property property; // Declare property to store final details