add condition

This commit is contained in:
Valentin CZERYBA 2024-11-23 13:14:24 +01:00
parent a0ece6f973
commit 23aec689f1

View File

@ -1,4 +1,3 @@
import 'package:covas_mobile/classes/alert.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart'; // Import dotenv
@ -122,6 +121,10 @@ class _MyHomePageState extends State<ListItemMenu> {
DateTime currentDateTime = DateTime.now();
var url = Uri.parse(
"${globals.api}/events?current_datetime=${currentDateTime.toString()}");
if (Datepicker.text.isNotEmpty) {
url = Uri.parse(
"${globals.api}/events?current_datetime=${currentDateTime.toString()}");
}
final response = await http.get(url, headers: {
"Content-Type": "application/json",
HttpHeaders.cookieHeader: "access_token=${accessToken}"
@ -307,6 +310,11 @@ class _MyHomePageState extends State<ListItemMenu> {
var url = Uri.parse("${globals.api}/events/search"
"?min_lat=$minLat&max_lat=$maxLat"
"&min_lon=$minLon&max_lon=$maxLon&current_datetime=${currentDate.toString()}");
if (Datepicker.text.isNotEmpty) {
url = Uri.parse("${globals.api}/events/search"
"?min_lat=$minLat&max_lat=$maxLat"
"&min_lon=$minLon&max_lon=$maxLon");
}
final response = await http.get(url, headers: {
"Content-Type": "application/json",
@ -343,7 +351,9 @@ class _MyHomePageState extends State<ListItemMenu> {
Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
if (inputGeo.text.isEmpty) {
_fetchInitialData();
} else {}
} else {
fetchPostsByLocation();
}
}
Padding _BuildDateField() {