add google place : NOK

This commit is contained in:
Valentin CZERYBA 2024-08-29 22:59:57 +02:00
parent af673b1abd
commit 0c2ab76cc9
3 changed files with 50 additions and 13 deletions

View File

@ -3,8 +3,9 @@ import 'package:flutter/widgets.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:mapbox_place_search/mapbox_place_search.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:google_places_autocomplete_text_field/google_places_autocomplete_text_field.dart';
import 'package:google_places_autocomplete_text_field/model/prediction.dart';
import 'dart:convert';
import 'dart:io';
@ -50,7 +51,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
TextEditingController endDatepicker = TextEditingController();
TextEditingController endTimepicker = TextEditingController();
String MAPBOX_API_KEY = "";
String GOOGLEMAP_API_KEY = "";
onTapFunctionDatePicker(
{required BuildContext context, required String position}) async {
@ -166,7 +167,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
void start() async {
await dotenv.load();
MAPBOX_API_KEY = dotenv.env['MAPBOX_API_KEY']!;
GOOGLEMAP_API_KEY = dotenv.env['GOOGLEMAP_API_KEY']!;
inputName.text = widget.events["name"];
inputPlace.text = widget.events["place"];
@ -219,7 +220,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
hintText: 'Modifier le nom de l\'évènement'),
),
),
Padding(
/* Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
@ -230,20 +231,39 @@ class _UpdateeventImageState extends State<UpdateeventImage>
labelText: 'Lieu',
hintText: 'Entrer le lieu'),
),
),
),*/
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: MapBoxPlaceSearchWidget(
popOnSelect: true,
apiKey: MAPBOX_API_KEY,
searchHint: widget.events["place"],
onSelected: (place) {
print("place : ${place.center}");
child: GooglePlacesAutoCompleteTextFormField(
textEditingController: inputPlace,
googleAPIKey: GOOGLEMAP_API_KEY,
decoration: const InputDecoration(
hintText: 'Enter your address',
labelText: 'Lieu',
labelStyle: TextStyle(color: Colors.purple),
border: OutlineInputBorder(),
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter some text';
}
return null;
},
context: context,
//iconAssetPath: './images/search.png',
// proxyURL: _yourProxyURL,
maxLines: 1,
overlayContainer: (child) => Material(
elevation: 1.0,
color: Colors.green,
borderRadius: BorderRadius.circular(12),
child: child,
),
getPlaceDetailWithLatLng: (prediction) {
print('placeDetails${prediction.lng}');
},
itmClick: (Prediction prediction) =>
inputPlace.text = prediction.description!,
),
),
Padding(

View File

@ -256,6 +256,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.4"
google_places_autocomplete_text_field:
dependency: "direct main"
description:
name: google_places_autocomplete_text_field
sha256: "86615529ffdef8901d6c4f9b23f2526884dcb69d28e411beceb8093f5a23911c"
url: "https://pub.dev"
source: hosted
version: "0.1.3"
http:
dependency: "direct main"
description:
@ -504,6 +512,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
url: "https://pub.dev"
source: hosted
version: "0.27.7"
shared_preferences:
dependency: "direct main"
description:

View File

@ -47,6 +47,7 @@ dependencies:
date_format_field: ^0.1.0
mapbox_search: ^4.2.2
mapbox_place_search: ^1.0.2
google_places_autocomplete_text_field: ^0.1.3
dev_dependencies:
flutter_test: