fix datepicker
This commit is contained in:
parent
c12a957099
commit
ac566053b1
@ -1,3 +1,5 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@ -54,10 +56,8 @@ class _EditEventState extends State<EditEvent>
|
||||
TextEditingController endTimepicker = TextEditingController();
|
||||
final _stringTagController = StringTagController();
|
||||
|
||||
var dateS = null;
|
||||
var timeS = null;
|
||||
var dateE = null;
|
||||
var timeE = null;
|
||||
DateTime startDate = DateTime.now();
|
||||
DateTime endDate = DateTime.now();
|
||||
List<Map<String, dynamic>> suggestions = [];
|
||||
String geographicalZone = "";
|
||||
String imgUrl = "";
|
||||
@ -86,10 +86,10 @@ class _EditEventState extends State<EditEvent>
|
||||
lastDate: DateTime(2104));
|
||||
if (pickedDate == null) return;
|
||||
if (position == "start") {
|
||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
startDatepicker.text = DateFormat("dd/MM/yyyy").format(pickedDate);
|
||||
}
|
||||
if (position == "end") {
|
||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
endDatepicker.text = DateFormat("dd/MM/yyyy").format(pickedDate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,9 +100,16 @@ class _EditEventState extends State<EditEvent>
|
||||
if ((startTimepicker.text.isEmpty) || (endTimepicker.text.isEmpty)) {
|
||||
time = TimeOfDay.now();
|
||||
} else {
|
||||
time = TimeOfDay.fromDateTime(DateTime.parse(startTimepicker.text));
|
||||
DateTime date = new DateTime.now();
|
||||
date = date.copyWith(
|
||||
hour: int.parse(startTimepicker.text.split(":")[0]),
|
||||
minute: int.parse(startTimepicker.text.split(":")[1]));
|
||||
time = TimeOfDay.fromDateTime(date);
|
||||
if (position == "end") {
|
||||
time = TimeOfDay.fromDateTime(DateTime.parse(endTimepicker.text));
|
||||
date = date.copyWith(
|
||||
hour: int.parse(endTimepicker.text.split(":")[0]),
|
||||
minute: int.parse(endTimepicker.text.split(":")[1]));
|
||||
time = TimeOfDay.fromDateTime(date);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +139,8 @@ class _EditEventState extends State<EditEvent>
|
||||
}
|
||||
|
||||
String formatDate(String date) {
|
||||
var splitedDate = date.split("-");
|
||||
var splitedDate = date.split("/");
|
||||
|
||||
var day = splitedDate[0];
|
||||
var month = splitedDate[1];
|
||||
var year = splitedDate[2];
|
||||
@ -164,14 +172,15 @@ class _EditEventState extends State<EditEvent>
|
||||
formerDesc = convertNulltoEmptyString(events["description"]);
|
||||
formerTags = List<String>.from(events['tags'] as List);
|
||||
formerOrga = List<String>.from(events['organizers'] as List);
|
||||
final startDate = DateTime.parse(events["start_date"]);
|
||||
dateS = DateFormat.yMd().format(startDate);
|
||||
timeS = DateFormat.Hm().format(startDate);
|
||||
startDate = DateTime.parse(events["start_date"]);
|
||||
//dateS = DateFormat.yMd().format(startDate);
|
||||
//print("startdate : ${dateS}");
|
||||
//timeS = DateFormat.Hm().format(startDate);
|
||||
|
||||
final endDate = DateTime.parse(events["end_date"]);
|
||||
endDate = DateTime.parse(events["end_date"]);
|
||||
|
||||
dateE = DateFormat.yMd().format(endDate);
|
||||
timeE = DateFormat.Hm().format(endDate);
|
||||
//dateE = DateFormat.yMd().format(endDate);
|
||||
//timeE = DateFormat.Hm().format(endDate);
|
||||
if (events["imgUrl"] != null) {
|
||||
formerImage = events["imgUrl"];
|
||||
}
|
||||
@ -227,10 +236,11 @@ class _EditEventState extends State<EditEvent>
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
inputName.text = formerName;
|
||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(dateS);
|
||||
startTimepicker.text = timeS.toString();
|
||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(dateE);
|
||||
endTimepicker.text = timeE.toString();
|
||||
startDatepicker.text =
|
||||
DateFormat("dd/MM/yyyy").format(startDate).toString();
|
||||
startTimepicker.text = DateFormat("HH:mm").format(startDate).toString();
|
||||
endDatepicker.text = DateFormat("dd/MM/yyyy").format(endDate).toString();
|
||||
endTimepicker.text = DateFormat("HH:mm").format(endDate).toString();
|
||||
initialOrga = formerOrga;
|
||||
inputGeo.text = formerMap;
|
||||
imgUrl = formerImage;
|
||||
|
Loading…
x
Reference in New Issue
Block a user