refactor: Replace HubsConstants.googlePlacesApiKey with AppConfig.googlePlacesApiKey for better configuration management

This commit is contained in:
Achintha Isuru
2026-02-04 08:47:43 -05:00
parent 1ba83e3ea6
commit e3268d4722
4 changed files with 8 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
/// AppConfig class that holds configuration constants for the application.
/// This class is used to access various API keys and other configuration values
/// throughout the app.
class AppConfig {
AppConfig._();
/// The Google Places API key used for address autocomplete functionality.
static const String googlePlacesApiKey = String.fromEnvironment('GOOGLE_PLACES_API_KEY');
}

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:firebase_auth/firebase_auth.dart' as firebase;
import 'package:firebase_data_connect/firebase_data_connect.dart';
import 'package:http/http.dart' as http;
import 'package:krow_core/core.dart';
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
import 'package:krow_domain/krow_domain.dart' as domain;
import 'package:krow_domain/krow_domain.dart'
@@ -262,7 +263,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
<String, String>{
'place_id': placeId,
'fields': 'address_component',
'key': HubsConstants.googlePlacesApiKey,
'key': AppConfig.googlePlacesApiKey,
},
);
try {

View File

@@ -2,6 +2,7 @@ import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:google_places_flutter/google_places_flutter.dart';
import 'package:google_places_flutter/model/prediction.dart';
import 'package:krow_core/core.dart';
import '../../util/hubs_constants.dart';
@@ -24,7 +25,7 @@ class HubAddressAutocomplete extends StatelessWidget {
return GooglePlaceAutoCompleteTextField(
textEditingController: controller,
focusNode: focusNode,
googleAPIKey: HubsConstants.googlePlacesApiKey,
googleAPIKey: AppConfig.googlePlacesApiKey,
debounceTime: 500,
countries: HubsConstants.supportedCountries,
isLatLngRequired: true,

View File

@@ -1,6 +1,3 @@
import 'package:krow_core/krow_core.dart';
class HubsConstants {
static const String googlePlacesApiKey = AppConfig.googlePlacesApiKey;
static const List<String> supportedCountries = <String>['us'];
}