display event with image
This commit is contained in:
parent
54247f8c56
commit
59bec53d9e
@ -69,6 +69,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||
String eventStartDate = "";
|
||||
String organizers = "";
|
||||
String place = "";
|
||||
String imgUrl = "";
|
||||
|
||||
Events? events;
|
||||
@override
|
||||
@ -85,6 +86,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||
String formerDate = "";
|
||||
String formerOrga = "";
|
||||
String formerMap = "";
|
||||
String formerImage = "";
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
|
||||
@ -102,8 +104,13 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||
final time = DateFormat.Hm().format(startDate);
|
||||
|
||||
final endDate = DateTime.parse(events["end_date"]);
|
||||
|
||||
final dateE = DateFormat.yMd().format(endDate);
|
||||
final timeE = DateFormat.Hm().format(endDate);
|
||||
if (events["imgUrl"] != null) {
|
||||
formerImage = events["imgUrl"];
|
||||
}
|
||||
|
||||
formerDate = "${date} ${time} à ${dateE} ${timeE}";
|
||||
if (events["organizers"].length > 1) {
|
||||
formerOrga = "${events['organizers'][0]}";
|
||||
@ -168,6 +175,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||
eventStartDate = formerDate;
|
||||
organizers = formerOrga;
|
||||
place = formerMap;
|
||||
imgUrl = formerImage;
|
||||
});
|
||||
}
|
||||
|
||||
@ -201,8 +209,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 60.0),
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: 250, child: Image.asset('images/flutter.png')),
|
||||
child: Container(height: 250, child: Image.network(imgUrl)),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@ -87,6 +88,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
}
|
||||
}
|
||||
|
||||
convertNulltoEmptyString(var check) {
|
||||
if (check == null) {
|
||||
return "";
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
String formatDate(String date) {
|
||||
var splitedDate = date.split("-");
|
||||
var day = splitedDate[0];
|
||||
@ -117,9 +125,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
List<String> send = ["toto"];
|
||||
if (accessToken.isNotEmpty) {
|
||||
try {
|
||||
await dotenv.load();
|
||||
final params = {
|
||||
'expiration': '600',
|
||||
'key': '87a91f7e54516808dda2c4feffbd5287',
|
||||
'expiration': '15552000',
|
||||
'key': dotenv.env["IMGBB_API_KEY"],
|
||||
};
|
||||
print("Post Img");
|
||||
final urlPost = Uri.parse('https://api.imgbb.com/1/upload')
|
||||
@ -221,15 +230,17 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
}
|
||||
|
||||
void start() async {
|
||||
inputName.text = widget.events["name"];
|
||||
inputCity.text = widget.events["city"];
|
||||
inputAddress.text = widget.events["address"];
|
||||
inputZipCode.text = widget.events["zip_code"];
|
||||
inputCountry.text = widget.events["country"];
|
||||
inputDesc.text = widget.events["description"];
|
||||
inputName.text = convertNulltoEmptyString(widget.events["name"]);
|
||||
inputCity.text = convertNulltoEmptyString(widget.events["city"]);
|
||||
inputAddress.text = convertNulltoEmptyString(widget.events["address"]);
|
||||
inputZipCode.text = convertNulltoEmptyString(widget.events["zip_code"]);
|
||||
inputCountry.text = convertNulltoEmptyString(widget.events["country"]);
|
||||
inputDesc.text = convertNulltoEmptyString(widget.events["description"]);
|
||||
|
||||
DateTime pickedStartDate = DateTime.parse(widget.events["start_date"]);
|
||||
DateTime pickedEndDate = DateTime.parse(widget.events["end_date"]);
|
||||
DateTime pickedStartDate =
|
||||
DateTime.parse(convertNulltoEmptyString(widget.events["start_date"]));
|
||||
DateTime pickedEndDate =
|
||||
DateTime.parse(convertNulltoEmptyString(widget.events["end_date"]));
|
||||
|
||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
|
||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user